MCPcopy Create free account
hub / github.com/bytedance/terarkdb / ReadFileToString

Function ReadFileToString

env/env.cc:328–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328Status ReadFileToString(Env* env, const std::string& fname, std::string* data) {
329 EnvOptions soptions;
330 data->clear();
331 std::unique_ptr<SequentialFile> file;
332 Status s = env->NewSequentialFile(fname, &file, soptions);
333 if (!s.ok()) {
334 return s;
335 }
336 static const int kBufferSize = 8192;
337 char* space = new char[kBufferSize];
338 while (true) {
339 Slice fragment;
340 s = file->Read(kBufferSize, &fragment, space);
341 if (!s.ok()) {
342 break;
343 }
344 data->append(fragment.data(), fragment.size());
345 if (fragment.empty()) {
346 break;
347 }
348 }
349 delete[] space;
350 return s;
351}
352
353EnvWrapper::~EnvWrapper() {}
354

Callers 9

DoCommandMethod · 0.85
CorruptFileMethod · 0.85
CorruptChecksumMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
GenerateUniqueIdMethod · 0.85
CorruptFileMethod · 0.85
RecoverMethod · 0.85
ListColumnFamiliesMethod · 0.85

Calls 8

clearMethod · 0.65
NewSequentialFileMethod · 0.45
okMethod · 0.45
ReadMethod · 0.45
appendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 5

CorruptFileMethod · 0.68
CorruptChecksumMethod · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
CorruptFileMethod · 0.68