Esempio n. 1
0
        internal void WriteTo(Stream stream)
        {
            var encoding = new DirectoryEntryEncoding();

            byte[] buffer = encoding.GetBytes(this, WriteTo);
            stream.Write(buffer, 0, buffer.Length);
        }
Esempio n. 2
0
        private void LoadEntries()
        {
            _entries     = new Dictionary <long, DirectoryEntry>();
            _freeEntries = new List <long>();

            _selfEntryLocation   = -1;
            _parentEntryLocation = -1;

            DirectoryEntryEncoding encoding = new DirectoryEntryEncoding();

            while (_dirStream.Position < _dirStream.Length)
            {
                long           streamPos = _dirStream.Position;
                DirectoryEntry entry     = encoding.GetDirectoryEntry(_fileSystem.FatOptions, _dirStream, _fileSystem.FatVariant);

                if (entry.Attributes == (FatAttributes.ReadOnly | FatAttributes.Hidden | FatAttributes.System | FatAttributes.VolumeId))
                {
                    // Long File Name entry
                    _entries.Add(streamPos, entry);
                }
                else if (entry.Name.IsDeleted())
                {
                    // E5 = Free Entry
                    _freeEntries.Add(streamPos);
                }
                else if (entry.Name == FileName.SelfEntryName)
                {
                    _selfEntry         = entry;
                    _selfEntryLocation = streamPos;
                }
                else if (entry.Name == FileName.ParentEntryName)
                {
                    _parentEntry         = entry;
                    _parentEntryLocation = streamPos;
                }
                else if (entry.Name.IsEndMarker())
                {
                    // Free Entry, no more entries available
                    _endOfEntries = streamPos;
                    break;
                }
                else
                {
                    _entries.Add(streamPos, entry);
                }
            }
        }