Example #1
0
        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;
        }
Example #2
0
        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.NormalizedName = SelfEntryNormalizedName;
                selfEntry.WriteTo(stream);

                // Second is a clone of our self entry (i.e. parent) - though dates are odd...
                DirectoryEntry parentEntry = new DirectoryEntry(SelfEntry);
                parentEntry.NormalizedName = ParentEntryNormalizedName;
                parentEntry.CreationTime   = newEntry.CreationTime;
                parentEntry.LastWriteTime  = newEntry.LastWriteTime;
                parentEntry.WriteTo(stream);
            }
        }