public GreenBookCdiDirectoryStructure(FileStream isoStream, string sourceFilePath, long baseOffset, GreenBookCdiDirectoryRecord directoryRecord, uint logicalBlockSize, bool isRaw, int nonRawSectorSize, string parentDirectory) { string nextDirectory; this.SourceFilePath = sourceFilePath; this.SubDirectoryArray = new ArrayList(); this.FileArray = new ArrayList(); if (String.IsNullOrEmpty(parentDirectory)) { this.ParentDirectoryName = String.Empty; this.DirectoryName = directoryRecord.FileIdentifierString; nextDirectory = this.DirectoryName; } else { this.ParentDirectoryName = parentDirectory; this.DirectoryName = directoryRecord.FileIdentifierString; nextDirectory = this.ParentDirectoryName + Path.DirectorySeparatorChar + this.DirectoryName; } this.parseDirectoryRecord(isoStream, baseOffset, directoryRecord, logicalBlockSize, isRaw, nonRawSectorSize, nextDirectory); }
private void parseDirectoryRecord(FileStream isoStream, long baseOffset, GreenBookCdiDirectoryRecord directoryRecord, uint logicalBlockSize, bool isRaw, int nonRawSectorSize, string parentDirectory) { byte recordSize; int currentOffset; uint bytesRead = 0; uint currentLba = directoryRecord.LocationOfExtent; byte[] directoryRecordBytes; GreenBookCdiDirectoryRecord tempDirectoryRecord; GreenBookCdiDirectoryStructure tempDirectory; GreenBookCdiFileStructure tempFile; byte[] directorySector = CdRom.GetSectorByLba(isoStream, baseOffset, currentLba, isRaw, nonRawSectorSize); directorySector = CdRom.GetDataChunkFromSector(directorySector, isRaw); currentOffset = 0; while (bytesRead < directoryRecord.DataLength) { recordSize = ParseFile.ParseSimpleOffset(directorySector, currentOffset, 1)[0]; if (recordSize > 0) { directoryRecordBytes = ParseFile.ParseSimpleOffset(directorySector, currentOffset, recordSize); tempDirectoryRecord = new GreenBookCdiDirectoryRecord(directoryRecordBytes); if (!tempDirectoryRecord.FileIdentifierString.Equals(".") && !tempDirectoryRecord.FileIdentifierString.Equals("..")) // skip "this" directory { //if (tempDirectoryRecord.FlagMultiExtent) //{ // int x = 1; //} if (tempDirectoryRecord.FlagDirectory) { tempDirectory = new GreenBookCdiDirectoryStructure(isoStream, isoStream.Name, baseOffset, tempDirectoryRecord, logicalBlockSize, isRaw, nonRawSectorSize, parentDirectory); this.SubDirectoryArray.Add(tempDirectory); } else { tempFile = new GreenBookCdiFileStructure(parentDirectory, this.SourceFilePath, tempDirectoryRecord.FileIdentifierString.Replace(";1", String.Empty), baseOffset, tempDirectoryRecord.LocationOfExtent, tempDirectoryRecord.DataLength, isRaw, nonRawSectorSize, tempDirectoryRecord.RecordingDateAndTime); this.FileArray.Add(tempFile); } } else if (tempDirectoryRecord.FileIdentifierString.Equals("..")) { this.ParentDirectoryRecord = tempDirectoryRecord; } bytesRead += recordSize; currentOffset += recordSize; } else if ((directoryRecord.DataLength - bytesRead) > (directorySector.Length - currentOffset)) { // move to start of next sector directorySector = CdRom.GetSectorByLba(isoStream, baseOffset, ++currentLba, isRaw, nonRawSectorSize); directorySector = CdRom.GetDataChunkFromSector(directorySector, isRaw); bytesRead += (uint)(logicalBlockSize - currentOffset); currentOffset = 0; } else { break; } } }