private static void InitializeSusp(IsoContext context, DirectoryRecord rootSelfRecord) { // Stage 1 - SUSP present? List <SuspExtension> extensions = new List <SuspExtension>(); if (!SuspRecords.DetectSharingProtocol(rootSelfRecord.SystemUseData, 0)) { context.SuspExtensions = new List <SuspExtension>(); context.SuspDetected = false; return; } else { context.SuspDetected = true; } SuspRecords suspRecords = new SuspRecords(context, rootSelfRecord.SystemUseData, 0); // Stage 2 - Init general SUSP params SharingProtocolSystemUseEntry spEntry = (SharingProtocolSystemUseEntry)suspRecords.GetEntries(null, "SP")[0]; context.SuspSkipBytes = spEntry.SystemAreaSkip; // Stage 3 - Init extensions List <SystemUseEntry> extensionEntries = suspRecords.GetEntries(null, "ER"); if (extensionEntries != null) { foreach (ExtensionSystemUseEntry extension in extensionEntries) { switch (extension.ExtensionIdentifier) { case "RRIP_1991A": case "IEEE_P1282": case "IEEE_1282": extensions.Add(new RockRidgeExtension(extension.ExtensionIdentifier)); context.RockRidgeIdentifier = extension.ExtensionIdentifier; break; default: extensions.Add(new GenericSuspExtension(extension.ExtensionIdentifier)); break; } } } else if (suspRecords.GetEntries(null, "RR") != null) { // Some ISO creators don't add the 'ER' record for RockRidge, but write the (legacy) // RR record anyway extensions.Add(new RockRidgeExtension("RRIP_1991A")); context.RockRidgeIdentifier = "RRIP_1991A"; } context.SuspExtensions = extensions; }
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; } } }