public int CompareTo(object obj) { if (obj is NullDcGdiDirectoryStructure) { NullDcGdiDirectoryStructure o = (NullDcGdiDirectoryStructure)obj; return(this.DirectoryName.CompareTo(o.DirectoryName)); } throw new ArgumentException("object is not an NullDcGdiDirectoryStructure"); }
public virtual void LoadDirectories(FileStream isoStream) { NullDcGdiDirectoryStructure.InitializeStruct dirInitStruct = new NullDcGdiDirectoryStructure.InitializeStruct(); // change name of top level folder this.DirectoryRecordForRootDirectory.FileIdentifierString = String.Empty; // populate this volume's directory structure dirInitStruct.Gdi = this.ParentGdi; dirInitStruct.SourceFilePath = isoStream.Name; dirInitStruct.BaseOffset = this.VolumeBaseOffset; dirInitStruct.DirectoryRecord = this.DirectoryRecordForRootDirectory; dirInitStruct.LogicalBlockSize = this.LogicalBlockSize; dirInitStruct.IsRaw = this.IsRawDump; dirInitStruct.NonRawSectorSize = this.SectorSize; dirInitStruct.VolumeContainsXaData = this.ContainsCdxaData; dirInitStruct.ParentDirectory = null; NullDcGdiDirectoryStructure rootDirectory = new NullDcGdiDirectoryStructure(dirInitStruct); this.DirectoryStructureArray.Add(rootDirectory); }
private void parseDirectoryRecord(InitializeStruct dirInitStruct) { byte recordSize; int currentOffset; uint bytesRead = 0; uint currentLba = dirInitStruct.DirectoryRecord.LocationOfExtent; byte[] directoryRecordBytes; NullDcGdiDirectoryRecord tempDirectoryRecord; NullDcGdiDirectoryStructure tempDirectory; NullDcGdiDirectoryStructure.InitializeStruct newDirInitStruct; NullDcGdiFileStructure tempFile; NullDcGdiFileStructure.InitializeStruct fileInitStruct = new NullDcGdiFileStructure.InitializeStruct(); byte[] directorySector = dirInitStruct.Gdi.GetSectorByLba(currentLba); directorySector = CdRom.GetDataChunkFromSector(directorySector, dirInitStruct.IsRaw); currentOffset = 0; while (bytesRead < dirInitStruct.DirectoryRecord.DataLength) { recordSize = ParseFile.ParseSimpleOffset(directorySector, currentOffset, 1)[0]; if (recordSize > 0) { try { directoryRecordBytes = ParseFile.ParseSimpleOffset(directorySector, currentOffset, recordSize); tempDirectoryRecord = new NullDcGdiDirectoryRecord(directoryRecordBytes, dirInitStruct.VolumeContainsXaData); if (!tempDirectoryRecord.FileIdentifierString.Equals(".") && !tempDirectoryRecord.FileIdentifierString.Equals("..")) // skip "this" directory { if (tempDirectoryRecord.FlagDirectory) { newDirInitStruct = dirInitStruct; newDirInitStruct.DirectoryRecord = tempDirectoryRecord; tempDirectory = new NullDcGdiDirectoryStructure(newDirInitStruct); this.SubDirectoryArray.Add(tempDirectory); } else { fileInitStruct.Gdi = dirInitStruct.Gdi; fileInitStruct.ParentDirectoryName = dirInitStruct.ParentDirectory; fileInitStruct.SourceFilePath = dirInitStruct.Gdi.GetFilePathForLba(tempDirectoryRecord.LocationOfExtent); fileInitStruct.FileName = tempDirectoryRecord.FileIdentifierString.Replace(";1", String.Empty); fileInitStruct.VolumeBaseOffset = dirInitStruct.BaseOffset; fileInitStruct.Lba = tempDirectoryRecord.LocationOfExtent; fileInitStruct.Size = tempDirectoryRecord.DataLength; fileInitStruct.IsRaw = dirInitStruct.IsRaw; fileInitStruct.NonRawSectorSize = dirInitStruct.NonRawSectorSize; fileInitStruct.FileMode = tempDirectoryRecord.ItemMode; fileInitStruct.FileTime = tempDirectoryRecord.RecordingDateAndTime; tempFile = new NullDcGdiFileStructure(fileInitStruct); this.FileArray.Add(tempFile); } } else if (tempDirectoryRecord.FileIdentifierString.Equals("..")) { this.ParentDirectoryRecord = tempDirectoryRecord; } bytesRead += recordSize; currentOffset += recordSize; } catch (Exception ex) { throw new Exception(String.Format("Error parsing directory structure at offset: {0}, {1}", currentOffset, ex.Message)); } } else if ((dirInitStruct.DirectoryRecord.DataLength - bytesRead) > (directorySector.Length - currentOffset)) { // move to start of next sector directorySector = dirInitStruct.Gdi.GetSectorByLba(++currentLba); directorySector = CdRom.GetDataChunkFromSector(directorySector, dirInitStruct.IsRaw); bytesRead += (uint)(dirInitStruct.LogicalBlockSize - currentOffset); currentOffset = 0; } else { break; } } }