Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArchiveFileAllocationTable"/> class.
        /// </summary>
        /// <param name="parent">An <see cref="ArchiveFile"/> object.</param>
        internal ArchiveFileAllocationTable(ArchiveFile parent)
        {
            m_parent              = parent;
            m_dataBlockPointers   = new List <ArchiveDataBlockPointer>();
            m_fixedTableRegion    = new FixedTableRegion(this);
            m_variableTableRegion = new VariableTableRegion(this);

            if (m_parent.FileData.Length == 0)
            {
                // File is brand new.
                m_fileStartTime  = TimeTag.MinValue;
                m_fileEndTime    = TimeTag.MinValue;
                m_dataBlockSize  = m_parent.DataBlockSize;
                m_dataBlockCount = ArchiveFile.MaximumDataBlocks(m_parent.FileSize, m_parent.DataBlockSize);

                for (int i = 0; i < m_dataBlockCount; i++)
                {
                    m_dataBlockPointers.Add(new ArchiveDataBlockPointer(m_parent, i));
                }
            }
            else
            {
                // Existing file, read table regions:

                // Seek to beginning of fixed table region
                m_parent.FileData.Seek(-m_fixedTableRegion.BinaryLength, SeekOrigin.End);

                // Parse fixed table region
                m_fixedTableRegion.ParseBinaryImageFromStream(m_parent.FileData);

                // Seek to beginning of variable table region (above fixed from bottom of file)
                m_parent.FileData.Seek(-(m_fixedTableRegion.BinaryLength + m_variableTableRegion.BinaryLength), SeekOrigin.End);

                // Parse variable table region
                m_variableTableRegion.ParseBinaryImageFromStream(m_parent.FileData);
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArchiveFileAllocationTable"/> class.
        /// </summary>
        /// <param name="parent">An <see cref="ArchiveFile"/> object.</param>
        internal ArchiveFileAllocationTable(ArchiveFile parent)
        {
            m_parent = parent;
            m_dataBlockPointers = new List<ArchiveDataBlockPointer>();
            m_fixedTableRegion = new FixedTableRegion(this);
            m_variableTableRegion = new VariableTableRegion(this);

            if (m_parent.FileData.Length == 0)
            {
                // File is brand new.
                m_fileStartTime = TimeTag.MinValue;
                m_fileEndTime = TimeTag.MinValue;
                m_dataBlockSize = m_parent.DataBlockSize;
                m_dataBlockCount = ArchiveFile.MaximumDataBlocks(m_parent.FileSize, m_parent.DataBlockSize);

                for (int i = 0; i < m_dataBlockCount; i++)
                {
                    m_dataBlockPointers.Add(new ArchiveDataBlockPointer(m_parent, i));
                }
            }
            else
            {
                // Existing file, read table regions:

                // Seek to beginning of fixed table region
                m_parent.FileData.Seek(-m_fixedTableRegion.BinaryLength, SeekOrigin.End);

                // Parse fixed table region
                m_fixedTableRegion.ParseBinaryImageFromStream(m_parent.FileData);

                // Seek to beginning of variable table region (above fixed from bottom of file)
                m_parent.FileData.Seek(-(m_fixedTableRegion.BinaryLength + m_variableTableRegion.BinaryLength), SeekOrigin.End);

                // Parse variable table region
                m_variableTableRegion.ParseBinaryImageFromStream(m_parent.FileData);
            }
        }