Beispiel #1
0
        public int CompareTo(object obj)
        {
            if (obj is Iso9660FileStructure)
            {
                Iso9660FileStructure o = (Iso9660FileStructure)obj;

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

            throw new ArgumentException("object is not an Iso9660FileStructure");
        }
Beispiel #2
0
        private void parseDirectoryRecord(InitializeStruct dirInitStruct)
        {
            byte recordSize;
            int  currentOffset;
            uint bytesRead  = 0;
            uint currentLba = dirInitStruct.DirectoryRecord.LocationOfExtent;

            byte[] directoryRecordBytes;
            Iso9660DirectoryRecord    tempDirectoryRecord;
            Iso9660DirectoryStructure tempDirectory;

            Iso9660DirectoryStructure.InitializeStruct newDirInitStruct;

            Iso9660FileStructure tempFile;

            Iso9660FileStructure.InitializeStruct fileInitStruct = new Iso9660FileStructure.InitializeStruct();

            byte[] directorySector = CdRom.GetSectorByLba(dirInitStruct.IsoStream, dirInitStruct.BaseOffset, currentLba, dirInitStruct.IsRaw, dirInitStruct.NonRawSectorSize);
            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 Iso9660DirectoryRecord(directoryRecordBytes, dirInitStruct.VolumeContainsXaData);

                        if (!tempDirectoryRecord.FileIdentifierString.Equals(".") &&
                            !tempDirectoryRecord.FileIdentifierString.Equals("..")) // skip "this" directory
                        {
                            if (tempDirectoryRecord.FlagDirectory)
                            {
                                newDirInitStruct = dirInitStruct;
                                newDirInitStruct.DirectoryRecord = tempDirectoryRecord;

                                tempDirectory = new Iso9660DirectoryStructure(newDirInitStruct);
                                this.SubDirectoryArray.Add(tempDirectory);
                            }
                            else
                            {
                                fileInitStruct.ParentDirectoryName = dirInitStruct.ParentDirectory;
                                fileInitStruct.SourceFilePath      = this.SourceFilePath;
                                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 Iso9660FileStructure(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 = CdRom.GetSectorByLba(dirInitStruct.IsoStream, dirInitStruct.BaseOffset, ++currentLba, dirInitStruct.IsRaw, dirInitStruct.NonRawSectorSize);
                    directorySector = CdRom.GetDataChunkFromSector(directorySector, dirInitStruct.IsRaw);
                    bytesRead      += (uint)(dirInitStruct.LogicalBlockSize - currentOffset);
                    currentOffset   = 0;
                }
                else
                {
                    break;
                }
            }
        }