MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / strip_cluster

Function strip_cluster

tools/comdb2ar/serialise.cpp:486–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

484}
485
486static void strip_cluster(const std::string& lrlpath,
487 const std::string& lrldest)
488{
489 std::ifstream instream(lrlpath.c_str());
490 if(!instream.is_open()) {
491 throw LRLError(lrlpath, 0, "cannot open file");
492 }
493
494 std::ofstream outstream(lrldest.c_str());
495 if(!outstream.is_open()) {
496 throw LRLError(lrldest, 0, "cannot open file");
497 }
498
499 while(!instream.eof()) {
500 std::string line;
501 std::getline(instream, line);
502
503 std::istringstream liness(line);
504
505 std::string tok;
506
507 if(liness >> tok && tok == "cluster") {
508 outstream << "#" << line << std::endl;
509 } else {
510 outstream << line << std::endl;
511 }
512 }
513}
514
515static bool file_exists(const std::string &path) {
516 int rc = access(path.c_str(), F_OK);

Callers 1

serialise_databaseFunction · 0.85

Calls 1

LRLErrorClass · 0.85

Tested by

no test coverage detected