/// <summary> /// Open a file. /// </summary> /// <param name="path">The path of the file to open</param> /// <returns>A stream serving the opened file</returns> public Stream OpenFile(string path) { ulong hash = HashFsFileName.GetHashForFullPath(path); foreach (ScsArchive arc in Archives) { if (arc.HasEntry(hash)) { return(new HashFsEntryReader(arc.GetEntry(hash)).GetStream()); } } throw new FileNotFoundException(path); }
/// <summary> /// List the contents of a folder. /// </summary> /// <param name="path">The path of the folder to list</param> /// <returns>An enumerable of full paths representing the contents of the folder</returns> public async Task <IEnumerable <string> > ListFolder(string path) { IEnumerable <string> contents = new LinkedList <string>(); ulong pathHash = HashFsFileName.GetHashForFullPath(path); foreach (ScsArchive arc in _archives.Values) { if (arc.HasEntry(pathHash)) { contents = contents.Union( (await new HashFsEntryReader(arc.GetEntry(pathHash)).ListFiles(path)) .Select((HashFsFileName x) => x.Name)); } } return(contents); }
/// <summary> /// Get an entry. /// </summary> /// <param name="path">Full path of the entry</param> /// <returns>The retrieved entry</returns> public HashFsEntry GetEntry(string path) => GetEntry(HashFsFileName.GetHashForFullPath(path));
/// <summary> /// Tells whether an entry is present. /// </summary> /// <param name="path">Full path to check for existence</param> /// <returns>True if the entry is present</returns> public bool HasEntry(string path) => HasEntry(HashFsFileName.GetHashForFullPath(path));