Esempio n. 1
0
        private ContinuationSystemUseEntry Parse(IsoContext context, byte[] data, int offset)
        {
            ContinuationSystemUseEntry contEntry = null;
            SuspExtension extension = null;

            if (context.SuspExtensions != null && context.SuspExtensions.Count > 0)
            {
                extension = context.SuspExtensions[0];
            }

            int pos = offset;

            while (data.Length - pos > 4)
            {
                int            len;
                SystemUseEntry entry = SystemUseEntry.Parse(data, pos, context.VolumeDescriptor.CharacterEncoding, extension, out len);
                pos += len;

                if (entry == null)
                {
                    // Skip if unknown
                    continue;
                }

                switch (entry.Name)
                {
                case "ST":
                    // Abort
                    return(contEntry);

                case "CE":
                    contEntry = (ContinuationSystemUseEntry)entry;
                    break;

                case "ES":
                    ExtensionSelectSystemUseEntry esEntry = (ExtensionSelectSystemUseEntry)entry;
                    extension = context.SuspExtensions[esEntry.SelectedExtension];
                    break;

                case "PD":
                    break;

                case "SP":
                case "ER":
                    StoreEntry(null, entry);
                    break;

                default:
                    StoreEntry(extension, entry);
                    break;
                }
            }

            return(contEntry);
        }
Esempio n. 2
0
        public ReaderDirectory(IsoContext context, ReaderDirEntry dirEntry)
            : base(context, dirEntry)
        {
            byte[] buffer = new byte[IsoUtilities.SectorSize];
            Stream extent = new ExtentStream(_context.DataStream, dirEntry.Record.LocationOfExtent, uint.MaxValue, 0, 0);

            _records = new List <ReaderDirEntry>();

            uint totalLength = dirEntry.Record.DataLength;
            uint totalRead   = 0;

            while (totalRead < totalLength)
            {
                int  toRead    = (int)Math.Min(buffer.Length, totalLength - totalRead);
                uint bytesRead = (uint)Utilities.ReadFully(extent, buffer, 0, toRead);
                if (bytesRead != toRead)
                {
                    throw new IOException("Failed to read whole directory");
                }

                totalRead += (uint)bytesRead;

                uint pos = 0;
                while (pos < bytesRead && buffer[pos] != 0)
                {
                    DirectoryRecord dr;
                    uint            length = (uint)DirectoryRecord.ReadFrom(buffer, (int)pos, context.VolumeDescriptor.CharacterEncoding, out dr);

                    if (!IsoUtilities.IsSpecialDirectory(dr))
                    {
                        ReaderDirEntry childDirEntry = new ReaderDirEntry(_context, dr);

                        if (context.SuspDetected && !string.IsNullOrEmpty(context.RockRidgeIdentifier))
                        {
                            if (childDirEntry.SuspRecords == null || !childDirEntry.SuspRecords.HasEntry(context.RockRidgeIdentifier, "RE"))
                            {
                                _records.Add(childDirEntry);
                            }
                        }
                        else
                        {
                            _records.Add(childDirEntry);
                        }
                    }
                    else if (dr.FileIdentifier == "\0")
                    {
                        _self = new ReaderDirEntry(_context, dr);
                    }

                    pos += length;
                }
            }
        }
Esempio n. 3
0
        public SuspRecords(IsoContext context, byte[] data, int offset)
        {
            _records = new Dictionary <string, Dictionary <string, List <SystemUseEntry> > >();

            ContinuationSystemUseEntry contEntry = Parse(context, data, offset + context.SuspSkipBytes);

            while (contEntry != null)
            {
                context.DataStream.Position = (contEntry.Block * (long)context.VolumeDescriptor.LogicalBlockSize) + contEntry.BlockOffset;
                byte[] contData = Utilities.ReadFully(context.DataStream, (int)contEntry.Length);

                contEntry = Parse(context, contData, 0);
            }
        }
Esempio n. 4
0
 public File(IsoContext context, ReaderDirEntry dirEntry)
 {
     _context = context;
     _dirEntry = dirEntry;
 }
Esempio n. 5
0
 public File(IsoContext context, ReaderDirEntry dirEntry)
 {
     _context  = context;
     _dirEntry = dirEntry;
 }
Esempio n. 6
0
        public ReaderDirEntry(IsoContext context, DirectoryRecord dirRecord)
        {
            _context = context;
            _record = dirRecord;
            _fileName = _record.FileIdentifier;

            if (context.SuspDetected && _record.SystemUseData != null)
            {
                _suspRecords = new SuspRecords(_context, _record.SystemUseData, 0);
            }

            if (!string.IsNullOrEmpty(_context.RockRidgeIdentifier))
            {
                // The full name is taken from this record, even if it's a child-link record
                List<SystemUseEntry> nameEntries = _suspRecords.GetEntries(_context.RockRidgeIdentifier, "NM");
                StringBuilder rrName = new StringBuilder();
                if (nameEntries != null && nameEntries.Count > 0)
                {
                    foreach (PosixNameSystemUseEntry nameEntry in nameEntries)
                    {
                        rrName.Append(nameEntry.NameData);
                    }

                    _fileName = rrName.ToString();
                }

                // If this is a Rock Ridge child link, replace the dir record with that from the 'self' record
                // in the child directory.
                ChildLinkSystemUseEntry clEntry = _suspRecords.GetEntry<ChildLinkSystemUseEntry>(_context.RockRidgeIdentifier, "CL");
                if (clEntry != null)
                {
                    _context.DataStream.Position = clEntry.ChildDirLocation * _context.VolumeDescriptor.LogicalBlockSize;
                    byte[] firstSector = Utilities.ReadFully(_context.DataStream, _context.VolumeDescriptor.LogicalBlockSize);

                    DirectoryRecord.ReadFrom(firstSector, 0, _context.VolumeDescriptor.CharacterEncoding, out _record);
                    if (_record.SystemUseData != null)
                    {
                        _suspRecords = new SuspRecords(_context, _record.SystemUseData, 0);
                    }
                }
            }

            _lastAccessTimeUtc = _record.RecordingDateAndTime;
            _lastWriteTimeUtc = _record.RecordingDateAndTime;
            _creationTimeUtc = _record.RecordingDateAndTime;

            if (!string.IsNullOrEmpty(_context.RockRidgeIdentifier))
            {
                FileTimeSystemUseEntry tfEntry = _suspRecords.GetEntry<FileTimeSystemUseEntry>(_context.RockRidgeIdentifier, "TF");

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Access) != 0)
                {
                    _lastAccessTimeUtc = tfEntry.AccessTime;
                }

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Modify) != 0)
                {
                    _lastWriteTimeUtc = tfEntry.ModifyTime;
                }

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Creation) != 0)
                {
                    _creationTimeUtc = tfEntry.CreationTime;
                }
            }
        }
Esempio n. 7
0
        public ReaderDirEntry(IsoContext context, DirectoryRecord dirRecord)
        {
            _context  = context;
            _record   = dirRecord;
            _fileName = _record.FileIdentifier;

            if (context.SuspDetected && _record.SystemUseData != null)
            {
                _suspRecords = new SuspRecords(_context, _record.SystemUseData, 0);
            }

            if (!string.IsNullOrEmpty(_context.RockRidgeIdentifier))
            {
                // The full name is taken from this record, even if it's a child-link record
                List <SystemUseEntry> nameEntries = _suspRecords.GetEntries(_context.RockRidgeIdentifier, "NM");
                StringBuilder         rrName      = new StringBuilder();
                if (nameEntries != null && nameEntries.Count > 0)
                {
                    foreach (PosixNameSystemUseEntry nameEntry in nameEntries)
                    {
                        rrName.Append(nameEntry.NameData);
                    }

                    _fileName = rrName.ToString();
                }

                // If this is a Rock Ridge child link, replace the dir record with that from the 'self' record
                // in the child directory.
                ChildLinkSystemUseEntry clEntry = _suspRecords.GetEntry <ChildLinkSystemUseEntry>(_context.RockRidgeIdentifier, "CL");
                if (clEntry != null)
                {
                    _context.DataStream.Position = clEntry.ChildDirLocation * _context.VolumeDescriptor.LogicalBlockSize;
                    byte[] firstSector = Utilities.ReadFully(_context.DataStream, _context.VolumeDescriptor.LogicalBlockSize);

                    DirectoryRecord.ReadFrom(firstSector, 0, _context.VolumeDescriptor.CharacterEncoding, out _record);
                    if (_record.SystemUseData != null)
                    {
                        _suspRecords = new SuspRecords(_context, _record.SystemUseData, 0);
                    }
                }
            }

            _lastAccessTimeUtc = _record.RecordingDateAndTime;
            _lastWriteTimeUtc  = _record.RecordingDateAndTime;
            _creationTimeUtc   = _record.RecordingDateAndTime;

            if (!string.IsNullOrEmpty(_context.RockRidgeIdentifier))
            {
                FileTimeSystemUseEntry tfEntry = _suspRecords.GetEntry <FileTimeSystemUseEntry>(_context.RockRidgeIdentifier, "TF");

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Access) != 0)
                {
                    _lastAccessTimeUtc = tfEntry.AccessTime;
                }

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Modify) != 0)
                {
                    _lastWriteTimeUtc = tfEntry.ModifyTime;
                }

                if ((tfEntry.TimestampsPresent & FileTimeSystemUseEntry.Timestamps.Creation) != 0)
                {
                    _creationTimeUtc = tfEntry.CreationTime;
                }
            }
        }