public FatFileStream(FatFileSystem fileSystem, Directory dir, long fileId, FileAccess access) { _dir = dir; _dirId = fileId; DirectoryEntry dirEntry = _dir.GetEntry(_dirId); _stream = new ClusterStream(fileSystem, access, (uint)dirEntry.FirstCluster, (uint)dirEntry.FileSize); _stream.FirstClusterChanged += FirstClusterAllocatedHandler; }
private void PopulateNewChildDirectory(DirectoryEntry newEntry) { // Populate new directory with initial (special) entries. First one is easy, just change the name! using (ClusterStream stream = new ClusterStream(_fileSystem, FileAccess.Write, newEntry.FirstCluster, uint.MaxValue)) { // First is the self-referencing entry... DirectoryEntry selfEntry = new DirectoryEntry(newEntry); selfEntry.Name = FileName.SelfEntryName; selfEntry.WriteTo(stream); // Second is a clone of our self entry (i.e. parent) - though dates are odd... DirectoryEntry parentEntry = new DirectoryEntry(SelfEntry); parentEntry.Name = FileName.ParentEntryName; parentEntry.CreationTime = newEntry.CreationTime; parentEntry.LastWriteTime = newEntry.LastWriteTime; parentEntry.WriteTo(stream); } }
private void LoadRootDirectory() { Stream fatStream; if (_type != FatType.Fat32) { fatStream = new SubStream(_data, (_bpbRsvdSecCnt + (_bpbNumFATs * _bpbFATSz16)) * _bpbBytesPerSec, _bpbRootEntCnt * 32); } else { fatStream = new ClusterStream(this, FileAccess.ReadWrite, _bpbRootClus, uint.MaxValue); } _rootDir = new Directory(this, fatStream); }