forked from cryfs/cryfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockStoreUtils.cpp
More file actions
31 lines (25 loc) · 806 Bytes
/
BlockStoreUtils.cpp
File metadata and controls
31 lines (25 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "../interface/BlockStore.h"
#include "BlockStoreUtils.h"
#include <cpp-utils/data/Data.h>
#include <cassert>
#include <cpp-utils/assert/assert.h>
using cpputils::Data;
using cpputils::unique_ref;
namespace blockstore {
namespace utils {
unique_ref<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(), "Can't copy block data when blocks have different sizes");
target->write(source.data(), 0, source.size());
}
void fillWithZeroes(Block *target) {
Data zeroes(target->size());
zeroes.FillWithZeroes();
target->write(zeroes.data(), 0, target->size());
}
}
}