Exemplo n.º 1
0
        public NullDcGdiDirectoryStructure(InitializeStruct initStruct)
        {
            InitializeStruct dirInitStruct = new InitializeStruct();
            string           nextDirectory;

            this.SourceFilePath    = initStruct.SourceFilePath;
            this.SubDirectoryArray = new ArrayList();
            this.FileArray         = new ArrayList();

            if (String.IsNullOrEmpty(initStruct.ParentDirectory))
            {
                this.ParentDirectoryName = String.Empty;
                this.DirectoryName       = initStruct.DirectoryRecord.FileIdentifierString;
                nextDirectory            = this.DirectoryName;
            }
            else
            {
                this.ParentDirectoryName = initStruct.ParentDirectory;
                this.DirectoryName       = initStruct.DirectoryRecord.FileIdentifierString;
                nextDirectory            = this.ParentDirectoryName + Path.DirectorySeparatorChar + this.DirectoryName;
            }

            dirInitStruct = initStruct;
            dirInitStruct.ParentDirectory = nextDirectory;

            this.parseDirectoryRecord(dirInitStruct);
        }
Exemplo n.º 2
0
 public Iso9660FileStructure(InitializeStruct initStruct)
 {
     this.ParentDirectoryName = initStruct.ParentDirectoryName;
     this.SourceFilePath      = initStruct.SourceFilePath;
     this.FileName            = initStruct.FileName;
     this.VolumeBaseOffset    = initStruct.VolumeBaseOffset;
     this.Lba              = initStruct.Lba;
     this.IsRaw            = initStruct.IsRaw;
     this.NonRawSectorSize = initStruct.NonRawSectorSize;
     this.Size             = initStruct.Size;
     this.FileMode         = initStruct.FileMode;
     this.FileDateTime     = initStruct.FileTime;
 }
Exemplo n.º 3
0
        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;
                }
            }
        }