Esempio n. 1
0
        public int CompareTo(object obj)
        {
            if (obj is NullDcGdiFileStructure)
            {
                NullDcGdiFileStructure o = (NullDcGdiFileStructure)obj;

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

            throw new ArgumentException("object is not an NullDcGdiFileStructure");
        }
Esempio n. 2
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;
                }
            }
        }