示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
            }
        }
示例#3
0
        /// <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);
        }
示例#4
0
 /// <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;
 }
示例#5
0
 /// <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);