private long GetNextCluster(long currentCluster) { if (Deleted) { // Just try reading contiguous blocks until we run out of space. // When a file is deleted in FAT, its entries are removed from // the allocation table. This code allows us to recover contiguous // deleted files. return(currentCluster + 1); } else { return(FileSystem.GetNextCluster(currentCluster)); } }
public FileFAT(FileSystemFAT fileSystem, long firstCluster) { FileSystem = fileSystem; FirstCluster = firstCluster; Name = Util.GetRandomString(8); Path = PathUtils.Combine(FileSystem.Store.DeviceID, "?", Name); long currentCluster = FirstCluster; _length = 0; while (currentCluster >= 0) { // Note: This won't correctly calculate the length of a deleted file. currentCluster = FileSystem.GetNextCluster(currentCluster); _length += FileSystem.BytesPerCluster; } Attributes = new FileAttributesFAT(); Deleted = true; }