libcryfs/utils/BlockStoreUtils.cpp
Sebastian Meßmer 417a701636 - BlockStore::create() gets the data of the new block as a parameter
- Fixed numBlocks() in OnDiskBlockStore, FakeBlockStore, CachingBlockStore, ...
- CachingBlockStore caches created blocks and doesn't directly create them in the underlying blockstore
2015-04-18 14:47:12 +02:00

31 lines
687 B
C++

#include "../interface/BlockStore.h"
#include "BlockStoreUtils.h"
#include "Data.h"
#include <memory>
#include <cassert>
using std::unique_ptr;
namespace blockstore {
namespace utils {
unique_ptr<Block> copyToNewBlock(BlockStore *blockStore, const Block &block) {
Data data(block.size());
std::memcpy(data.data(), block.data(), block.size());
return blockStore->create(data);
}
void copyTo(Block *target, const Block &source) {
assert(target->size() == source.size());
target->write(source.data(), 0, source.size());
}
void fillWithZeroes(Block *target) {
Data zeroes(target->size());
zeroes.FillWithZeroes();
target->write(zeroes.data(), 0, target->size());
}
}
}