private void BuildFirstClusterIndex() { if (_firstClusterIndex == null) { // Iterate over all files on the drive and record their first cluster. // Newer files overwrite older files. _firstClusterIndex = new Dictionary <long, IFATNode>(); SearchByTree(new NodeVisitCallback(delegate(INodeMetadata metadata, ulong progress, ulong total) { // Handle files FileFAT file = metadata as FileFAT; if (file != null) { if (!_firstClusterIndex.ContainsKey(file.FirstCluster) || _firstClusterIndex[file.FirstCluster].LastModified < file.LastModified) { _firstClusterIndex[file.FirstCluster] = file; } } // Handle folders FolderFAT folder = metadata as FolderFAT; if (folder != null) { if (!_firstClusterIndex.ContainsKey(folder.FirstCluster) || _firstClusterIndex[folder.FirstCluster].LastModified < folder.LastModified) { _firstClusterIndex[folder.FirstCluster] = folder; } } return(true); }), null); } }
public FileFAT(FileSystemFAT fileSystem, FolderFAT.DirectoryEntry entry, string path) { FileSystem = fileSystem; Name = PathUtils.MakeFileNameValid(entry.FileName); Path = PathUtils.Combine(path, Name); _length = entry.Length; Attributes = new FileAttributesFAT(entry); FirstCluster = entry.ClusterNum; Deleted = Attributes.Deleted; }
public FileAttributesFAT(FolderFAT.DirectoryEntry entry) { Name = entry.FileName; Size = (ulong)entry.Length; Deleted = entry.Free; Hidden = (entry.Attributes & FATDirectoryAttributes.ATTR_HIDDEN) != 0; System = (entry.Attributes & FATDirectoryAttributes.ATTR_SYSTEM) != 0; Archive = (entry.Attributes & FATDirectoryAttributes.ATTR_ARCHIVE) != 0; ReadOnly = (entry.Attributes & FATDirectoryAttributes.ATTR_READ_ONLY) != 0; Created = entry.CreationTime; LastModified = entry.LastWrite; LastAccessed = entry.LastAccess; }