Ejemplo n.º 1
0
        // Constructors

        /// <summary>
        /// DataTrack (abstract)
        /// </summary>
        /// <param name="fileStream">The iso file stream</param>
        /// <param name="trackNumber">The track number</param>
        /// <param name="system">File system used for this data track</param>
        /// <param name="mode">The sector mode of the track</param>
        internal DataTrack(FileStream fileStream, int trackNumber, DiskFileSystem system, DataTrackMode mode)
            : base(fileStream, trackNumber, TrackType.DATA)
        {
            _system     = system;
            _mode       = mode;
            _sectorSize = mode == DataTrackMode.RAW ? 2048 : 2352;
            _isXa       = false;
            _pregapSize = 150;

            switch (_mode)
            {
            case DataTrackMode.MODE1:
                _defaultSectorMode = SectorMode.MODE1;
                break;

            case DataTrackMode.MODE2:
                _defaultSectorMode = SectorMode.MODE2;
                break;

            case DataTrackMode.MODE2_XA:
                _defaultSectorMode = SectorMode.XA_FORM1;
                _isXa = true;
                break;

            case DataTrackMode.RAW:
            default:
                _defaultSectorMode = SectorMode.RAW;
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a data track
        /// </summary>
        /// <param name="mode">The sector mode of the track</param>
        /// <returns></returns>
        public DataTrackWriter CreateDataTrack(DataTrackMode mode)
        {
            if (_hasDataTrack)
            {
                throw new FrameworkException("Error while adding track : only Mixed Mode multi tracks disks are supported, it must contains only one DATA track");
            }

            var dataTrack = new DataTrackWriter(_stream, TracksCount + 1, _system, mode);

            _tracks.Add(dataTrack);
            _hasDataTrack = true;

            return(dataTrack);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// DiskReader (single data track)
        /// </summary>
        /// <param name="fileUrl">Path to the ISO/BIN/IMG file to read</param>
        /// <param name="system">File system used for the data track</param>
        /// <param name="mode">The sector mode of the track</param>
        /// <param name="readDescriptors">Read descriptors immediately</param>
        /// <param name="buildIndex">Build the index cache immediately</param>
        private DiskReader(string fileUrl, DiskFileSystem system, DataTrackMode mode, bool readDescriptors = true, bool buildIndex = true)
            : base(system)
        {
            try
            {
                _file       = new FileInfo(fileUrl);
                _fileStream = new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
                _stream     = new CBinaryReader(_fileStream);
                _fileOpen   = true;

                _stream.Position = 0;

                _tracks.Add(new DataTrackReader(_stream, 1, system, mode, readDescriptors, buildIndex));
            }
            catch (FrameworkException ex)
            {
                throw ex;
            }
            catch (Exception)
            {
                throw new FrameworkException("Error while reading ISO : Unable to open the ISO File");
            }
        }
Ejemplo n.º 4
0
        // Constructors

        /// <summary>
        /// DataTrackWriter
        /// </summary>
        /// <param name="stream">The stream of iso</param>
        /// <param name="trackNumber">The track number</param>
        /// <param name="system">File system used for this data track</param>
        /// <param name="mode">The sector mode of the track</param>
        internal DataTrackWriter(CBinaryWriter stream, int trackNumber, DiskFileSystem system, DataTrackMode mode)
            : base((FileStream)stream.BaseStream, trackNumber, system, mode)
        {
            _stream    = stream;
            _prepared  = false;
            _finalized = false;
            _appendVersionToFileName = true;

            try
            {
                // Allocation for system area
                WriteEmptySectors(16);
            }
            catch (FrameworkException ex)
            {
                throw ex;
            }
            catch (Exception)
            {
                throw new FrameworkException("Error while while writing data track : unable to write the data track");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initialize a new single data track DiskReader
 /// </summary>
 /// <param name="fileUrl">Path to the ISO/BIN/IMG file to read</param>
 /// <param name="system">File system used for the track</param>
 /// <param name="mode">The sector mode of the track</param>
 /// <param name="readDescriptors">Read descriptors immediately</param>
 /// <param name="buildIndex">Build the index cache immediately</param>
 public static DiskReader InitFromIso(string fileUrl, DiskFileSystem system, DataTrackMode mode, bool readDescriptors = true, bool buildIndex = true)
 {
     return(new DiskReader(fileUrl, system, mode, readDescriptors, buildIndex));
 }
Ejemplo n.º 6
0
        // Constructors

        /// <summary>
        /// DataTrackReader
        /// </summary>
        /// <param name="stream">The stream of iso</param>
        /// <param name="trackNumber">The track number</param>
        /// <param name="system">File system used for this data track</param>
        /// <param name="mode">The sector mode of the track</param>
        /// <param name="readDescriptors">Read descriptors immediately</param>
        /// <param name="buildIndex">Build the index cache immediately</param>
        internal DataTrackReader(CBinaryReader stream, int trackNumber, DiskFileSystem system, DataTrackMode mode, bool readDescriptors = true, bool buildIndex = true)
            : base((FileStream)stream.BaseStream, trackNumber, system, mode)
        {
            _stream          = stream;
            _descriptorsRead = false;
            _indexBuilt      = false;
            _entriesOrder    = DataTrackEntriesOrder.DEFAULT;

            try
            {
                if (readDescriptors)
                {
                    ReadVolumeDescriptors();
                }

                if (buildIndex)
                {
                    BuildIndex();
                }

                SeekSector(0);
            }
            catch (FrameworkException ex)
            {
                throw ex;
            }
            catch (Exception)
            {
                throw new FrameworkException("Error while reading data track : unable to read the data track");
            }
        }