예제 #1
0
        public int CompareTo(object obj)
        {
            if (obj is GreenBookCdiFileStructure)
            {
                GreenBookCdiFileStructure o = (GreenBookCdiFileStructure)obj;

                return(this.FileName.CompareTo(o.FileName));
            }

            throw new ArgumentException("object is not an GreenBookCdiFileStructure");
        }
예제 #2
0
        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;
                }
            }
        }