示例#1
0
    /**
     * @brief write a given file block to disk
     * @param io the core io data structure
     * @param out the image stream to write to
     * @param block the block to write out
     */
    inline void writeBlock(SharedCoreIO const &io, ContainerImageStream &out, uint64_t const block)
    {
        std::vector<uint8_t> ints;
        ints.assign(FILE_BLOCK_SIZE - FILE_BLOCK_META, 0);

        // write out block metadata
        uint64_t offset = getOffsetOfFileBlock(block, io->blocks);
        (void)out.seekp(offset);

        // write m_bytesWritten; 0 to begin with
        uint8_t sizeDat[4];
        uint32_t size = 0;
        convertInt32ToInt4Array(size, sizeDat);
        (void)out.write((char*)sizeDat, 4);

        // write m_next; begins as same as index
        uint8_t nextDat[8];
        convertUInt64ToInt8Array(block, nextDat);
        (void)out.write((char*)nextDat, 8);

        // write data bytes
        (void)out.write((char*)&ints.front(), FILE_BLOCK_SIZE - FILE_BLOCK_META);

        assert(!out.bad());
    }
示例#2
0
 /**
  * @brief gets the next file block index from the given file block
  * @param in the knoxcrypt image stream
  * @param n the file block to get the next index from
  * @param totalBlocks the total number of blocks in the knoxcrypt
  * @return the next file block index
  */
 inline uint64_t getIndexOfNextFileBlockFromFileBlockN(knoxcrypt::ContainerImageStream &in,
                                                       uint64_t const n,
                                                       uint64_t const totalBlocks)
 {
     auto offset = getOffsetOfFileBlock(n, totalBlocks) + 4;
     (void)in.seekg(offset);
     uint8_t dat[8];
     (void)in.read((char*)dat, 8);
     return convertInt8ArrayToInt64(dat);
 }
示例#3
0
 /**
  * @brief gets the next file block index from the given file block
  * @param in the knoxcrypt image stream
  * @param n the file block to get the next index from
  * @param totalBlocks the total number of blocks in the knoxcrypt
  * @return the next file block index
  */
 inline uint32_t getNumberOfDataBytesWrittenToFileBlockN(knoxcrypt::ContainerImageStream &in,
                                                         uint64_t const n,
                                                         uint64_t const totalBlocks)
 {
     uint64_t offset = getOffsetOfFileBlock(n, totalBlocks);
     (void)in.seekg(offset);
     uint8_t dat[4];
     (void)in.read((char*)dat, 4);
     return convertInt4ArrayToInt32(dat);
 }
示例#4
0
 /**
  * @brief gets the next file block index from the given file block
  * @param in the teasafe image stream
  * @param n the file block to get the next index from
  * @param totalBlocks the total number of blocks in the teasafe
  * @return the next file block index
  */
 inline uint64_t getIndexOfNextFileBlockFromFileBlockN(teasafe::TeaSafeImageStream &in,
                                                       uint64_t const n,
                                                       uint64_t const totalBlocks)
 {
     uint64_t offset = getOffsetOfFileBlock(n, totalBlocks) + 4;
     (void)in.seekg(offset);
     uint8_t dat[8];
     (void)in.read((char*)dat, 8);
     return convertInt8ArrayToInt64(dat);
 }