 |
ewmscp
..
|
Go to the documentation of this file.
25 static const block* data =
nullptr;
26 if (data ==
nullptr) {
28 auto buffer =
new block(16*1024*1024);
29 std::default_random_engine re;
30 for (
auto p=
static_cast<decltype(re)::result_type*
>(buffer->bufferAt(0));
31 p <
static_cast<decltype(re)::result_type*
>(buffer->bufferAt(buffer->max_size()/
sizeof(*p)));
35 buffer->bump_size(buffer->max_size());
47 return std::unique_ptr<base::reader>(
new readerDummy(aPath,
73 b.
clear(totalBytesRead);
74 auto bytesToRead = readInitialStat.size - totalBytesRead;
80 throw std::runtime_error(
"random data block too small");
88 totalBytesRead += bytesToRead;
89 return totalBytesRead >= readInitialStat.size;
98 throw std::runtime_error(
"random data block too small");
113 return std::unique_ptr<const genericStat>(
new genericStat(readInitialStat));
121 if (path.find(
"/dummy/") == 0) {
122 auto basename = path.substr(path.find_last_of(
'/')+1);
125 if (basename.find(
"file_") == 0) {
126 stat->mode = S_IFREG;
127 stat->size = std::stoll(basename.substr(5));
132 stat->mode = S_IFDIR;
134 return std::unique_ptr<const genericStat>(stat);
137 return posixHandler.
getStat(path, followLink);
142 if (path.find(
"/dummy/") == 0) {
143 auto basename = path.substr(path.find_last_of(
'/')+1);
144 if (basename.empty()) {
146 }
else if (basename.find(
"dir_") == 0) {
147 level = std::stoul(basename.substr(4));
149 throw std::logic_error(aPath +
" is not a directory");
162 throw std::logic_error(
"dummy directories mist start with /dummy/, not " + aPath);
170 std::string name(
"file_");
171 auto stat = std::unique_ptr<genericStat>(
new genericStat);
173 static std::default_random_engine rnd;
175 stat->device = 12345;
176 stat->mode = S_IFREG;
180 name += std::to_string(stat->size);
182 name += std::to_string(nFilesLeft);
183 return std::unique_ptr<Entry>(
new Entry(name, stat));
184 }
else if (nDirsLeft) {
186 std::string name(
"dir_");
187 auto stat = std::unique_ptr<genericStat>(
new genericStat);
188 stat->device = 12345;
189 stat->mode = S_IFDIR;
192 name += std::to_string(
level+1);
194 name += std::to_string(nDirsLeft);
195 return std::unique_ptr<Entry>(
new Entry(name, stat));
200 if (path.find(
"/dummy/") == 0) {
generic stat abstraction class Used to abstract the variants of the stat structure.
void bump_size(size_t additionalBytes)
void * bufferAt(size_t offset)
only way to access the data in the block
data block, used to hold the data that are being copied (or checksummed).
std::unique_ptr< const genericStat > getStat(const std::string &path, bool followLink) override
#define timerInst(subfunc)
class as base for inputHandler::base::reader and outputHandler::base::writer containing the common pa...
void clear(size_t aOffset)
static options::single< std::string > distribution('d', "distribution", "distribution type", "constant", {"constant", "uniform", "geometric", "gauss"})
#define defineStatic(var,...)
defines a static variable and instatitates the constructor with the variable number of arguments.