コード例 #1
0
 /// <summary>block header, 6 bytes</summary>
 /// <exception cref="Com.Khubla.Pdxreader.Api.PDXReaderException"/>
 public virtual void Read(LittleEndianDataInputStream littleEndianDataInputStream)
 {
     try
     {
         nextBlockNumber     = littleEndianDataInputStream.ReadUnsignedShort();
         previousBlockNumber = littleEndianDataInputStream.ReadUnsignedShort();
         offsetLastRecord    = littleEndianDataInputStream.ReadUnsignedShort();
     }
     catch (Exception e)
     {
         throw new PDXReaderException("Exception in read", e);
     }
 }
コード例 #2
0
ファイル: MBTableBlock.cs プロジェクト: dabide/NParadoxReader
 /// <exception cref="System.IO.IOException"/>
 public virtual int PreRead(LittleEndianDataInputStream littleEndianDataInputStream
                            )
 {
     sizeofBlock = BlockSizeMultiplier * littleEndianDataInputStream.ReadUnsignedShort
                       ();
     return(2);
 }
コード例 #3
0
 /// <exception cref="Com.Khubla.Pdxreader.Api.PDXReaderException"/>
 public override void Read(LittleEndianDataInputStream littleEndianDataInputStream
                           )
 {
     try
     {
         int blockType = littleEndianDataInputStream.ReadByte();
         if (blockType != base.recordType.GetValue())
         {
             throw new PDXReaderException("Block type mismatch");
         }
         int sizeofBlock = littleEndianDataInputStream.ReadUnsignedShort();
         if ((sizeofBlock * BlockSizeMultiplier) != base.sizeofBlock)
         {
             throw new PDXReaderException("Block type mismatch");
         }
         modificationCount = littleEndianDataInputStream.ReadUnsignedShort();
     }
     catch (IOException e)
     {
         throw new PDXReaderException("Exception reading inputStream", e);
     }
 }
コード例 #4
0
ファイル: PXFileHeader.cs プロジェクト: dabide/NParadoxReader
        /// <summary>read (little endian)</summary>
        /// <exception cref="Com.Khubla.Pdxreader.Api.PDXReaderException"/>
        public virtual void Read(LittleEndianDataInputStream littleEndianDataInputStream)
        {
            try
            {
                /*
                 * The index record length is six greater than the sum of the lengths of the key fields.
                 */
                indexRecordLength = littleEndianDataInputStream.ReadUnsignedShort();
                headerBlockSize   = littleEndianDataInputStream.ReadUnsignedShort();
                if (2048 != headerBlockSize)
                {
                    throw new Exception("headerBlockSize was expected to be 2048, but '" + headerBlockSize
                                        + "' was found");
                }
                int fileType = littleEndianDataInputStream.ReadUnsignedByte();
                if (1 != fileType)
                {
                    throw new Exception("PX file type was expected to be 1, but '" + fileType + "' was found"
                                        );
                }
                dataBlockSizeCode = littleEndianDataInputStream.ReadUnsignedByte();
                if (1 == dataBlockSizeCode)
                {
                    blockSize = PXFileHeader.BlockSize.oneK;
                }
                else
                {
                    if (2 == dataBlockSizeCode)
                    {
                        blockSize = PXFileHeader.BlockSize.twoK;
                    }
                    else
                    {
                        if (3 == dataBlockSizeCode)
                        {
                            blockSize = PXFileHeader.BlockSize.threeK;
                        }
                        else
                        {
                            if (4 == dataBlockSizeCode)
                            {
                                blockSize = PXFileHeader.BlockSize.fourK;
                            }
                            else
                            {
                                throw new Exception("Unknown block size code '" + dataBlockSizeCode + "'");
                            }
                        }
                    }
                }
                numberRecords     = littleEndianDataInputStream.ReadInt();
                blocksInUse       = littleEndianDataInputStream.ReadUnsignedShort();
                totalBlocksInFile = littleEndianDataInputStream.ReadUnsignedShort();
                firstDataBlock    = littleEndianDataInputStream.ReadUnsignedShort();
                if (1 != firstDataBlock)
                {
                    throw new Exception("firstDataBlock was expected to be 1, but '" + firstDataBlock
                                        + "' was found");
                }
                lastDataBlock     = littleEndianDataInputStream.ReadUnsignedShort();
                indexRootBlock    = littleEndianDataInputStream.ReadUnsignedShort();
                numberIndexLevels = littleEndianDataInputStream.ReadUnsignedByte();

                /*
                 * The number of fields in the index is the same as the number of key fields for the table.
                 */
                numberIndexFields = littleEndianDataInputStream.ReadUnsignedByte();
            }
            catch (Exception e)
            {
                throw new PDXReaderException("Exception in read", e);
            }
        }
コード例 #5
0
        /// <summary>read (little endian)</summary>
        /// <exception cref="System.Exception"/>
        public virtual void Read(LittleEndianDataInputStream littleEndianDataInputStream)
        {
            try
            {
                recordBufferSize = littleEndianDataInputStream.ReadUnsignedShort();
                headerBlockSize  = littleEndianDataInputStream.ReadUnsignedShort();
                int tableType = littleEndianDataInputStream.ReadUnsignedByte();
                if (0 == tableType)
                {
                    this.tableType = DBTableHeader.TableType.keyed;
                }
                else
                {
                    if (2 == tableType)
                    {
                        this.tableType = DBTableHeader.TableType.unkeyed;
                    }
                    else
                    {
                        throw new Exception("Unknown table type '" + tableType + "'");
                    }
                }
                dataBlockSizeCode = littleEndianDataInputStream.ReadUnsignedByte();
                if (1 == dataBlockSizeCode)
                {
                    blockSize = DBTableHeader.BlockSize.oneK;
                }
                else
                {
                    if (2 == dataBlockSizeCode)
                    {
                        blockSize = DBTableHeader.BlockSize.twoK;
                    }
                    else
                    {
                        if (3 == dataBlockSizeCode)
                        {
                            blockSize = DBTableHeader.BlockSize.threeK;
                        }
                        else
                        {
                            if (4 == dataBlockSizeCode)
                            {
                                blockSize = DBTableHeader.BlockSize.fourK;
                            }
                            else
                            {
                                throw new Exception("Unknown block size code '" + dataBlockSizeCode + "'");
                            }
                        }
                    }
                }
                numberRecords     = littleEndianDataInputStream.ReadInt();
                blocksInUse       = littleEndianDataInputStream.ReadUnsignedShort();
                totalBlocksInFile = littleEndianDataInputStream.ReadUnsignedShort();
                firstDataBlock    = littleEndianDataInputStream.ReadUnsignedShort();
                lastDataBlock     = littleEndianDataInputStream.ReadUnsignedShort();
                littleEndianDataInputStream.SkipBytes(15);
                // byte 0x21
                numberFields = littleEndianDataInputStream.ReadUnsignedByte();
                // byte 0x22
                littleEndianDataInputStream.SkipBytes(1);
                // byte 0x23
                numberKeyFields = littleEndianDataInputStream.ReadUnsignedByte();
                littleEndianDataInputStream.SkipBytes(unchecked ((int)(0x54)));
                // byte 0x78
                ReadFieldTypesAndSizes(littleEndianDataInputStream);
                // name
                littleEndianDataInputStream.SkipBytes(20);
                embeddedFilename = StringUtil.ReadString(littleEndianDataInputStream);

                /*
                 * skip forward 250 bytes
                 */
                int skipBytes = 250;
                // dumpBytes(skipBytes, littleEndianDataInputStream);
                littleEndianDataInputStream.SkipBytes(skipBytes);
                ReadFieldNames(littleEndianDataInputStream);
            }
            catch (Exception e)
            {
                throw new Exception("Exception in read", e);
            }
        }