/// <summary> /// Finds the file at the given virtual path from the tree. /// </summary> /// <param name="filePath">The path of the file to find.</param> /// <returns>The <see cref="AegisFileInfo"/> associated with the file, or null if not found.</returns> public AegisFileInfo Find(AegisVirtualFilePath filePath) { var node = this.GetNodeForDirectoryPath(filePath.DirectoryPath); return(node?.Files.ContainsKey(filePath.FileName) == true ? node.Files[filePath.FileName] : null); }
/// <summary> /// Removes information about a file from the index. /// </summary> /// <param name="filePath">The virtual path of the file to remove.</param> public void Remove(AegisVirtualFilePath filePath) { var fileInfo = this.FileTree.Remove(filePath); if (fileInfo is object) { this.FileEntriesById.Remove(fileInfo.FileId); } }
/// <summary> /// Removes the file at the given virtual path from the tree. /// </summary> /// <param name="filePath">The path of the file to remove.</param> /// <returns>The <see cref="AegisFileInfo"/> of the file that was removed, or null if it wasn't found.</returns> public AegisFileInfo Remove(AegisVirtualFilePath filePath) { var fileInfo = default(AegisFileInfo); var treeNode = this.GetNodeForDirectoryPath(filePath.DirectoryPath); if (treeNode?.Files.ContainsKey(filePath.FileName) == true) { fileInfo = treeNode.Files[filePath.FileName]; treeNode.Files.Remove(filePath.FileName); PruneNodeIfNeeded(treeNode); } return(fileInfo); }
/// <summary> /// Initializes a new instance of the <see cref="AegisFileInfo"/> class. /// </summary> /// <param name="path">The virtual path to the file.</param> /// <param name="indexEntry">The underlying index entry for the file.</param> internal AegisFileInfo(AegisVirtualFilePath path, FileIndexEntry indexEntry) { this.Path = path; this.IndexEntry = indexEntry; }
/// <summary> /// Retrieves information about a file in the archive. /// </summary> /// <param name="filePath">The virual path to the file.</param> /// <returns>The <see cref="AegisFileInfo"/> about the file, or null if it isn't found.</returns> public AegisFileInfo GetFileInfo(AegisVirtualFilePath filePath) => this.FileTree.Find(filePath);