Ejemplo n.º 1
0
        public int CompareTo(object obj)
        {
            if (obj is Iso9660DirectoryStructure)
            {
                Iso9660DirectoryStructure o = (Iso9660DirectoryStructure)obj;

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

            throw new ArgumentException("object is not an Iso9660DirectoryStructure");
        }
Ejemplo n.º 2
0
        public virtual void LoadDirectories(FileStream isoStream)
        {
            Iso9660DirectoryStructure.InitializeStruct dirInitStruct = new Iso9660DirectoryStructure.InitializeStruct();

            // change name of top level folder
            this.DirectoryRecordForRootDirectory.FileIdentifierString = String.Empty;

            // populate this volume's directory structure
            dirInitStruct.IsoStream            = isoStream;
            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;

            Iso9660DirectoryStructure rootDirectory = new Iso9660DirectoryStructure(dirInitStruct);

            this.DirectoryStructureArray.Add(rootDirectory);
        }
Ejemplo n.º 3
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;
                }
            }
        }