public ReaderDirectory(IsoContext context, DirectoryRecord dirEntry) : base(context, dirEntry) { byte[] buffer = new byte[IsoUtilities.SectorSize]; Stream extent = new ExtentStream(_context.DataStream, dirEntry.LocationOfExtent, uint.MaxValue, 0, 0); _records = new List <DirectoryRecord>(); uint totalLength = dirEntry.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)) { _records.Add(dr); } else if (dr.FileIdentifier == "\0") { _self = dr; } pos += length; } } }
public File(IsoContext context, DirectoryRecord dirEntry) { _context = context; _dirEntry = dirEntry; }