MCPcopy Create free account
hub / github.com/bytedance/bolt / restoreStringFromFile

Function restoreStringFromFile

bolt/vector/VectorSaver.cpp:704–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704std::string restoreStringFromFile(const char* FOLLY_NONNULL filePath) {
705 std::ifstream inputFile(filePath, std::ifstream::binary);
706 BOLT_CHECK(!inputFile.fail(), "Cannot open file: {}", filePath);
707
708 // Find out file size.
709 auto begin = inputFile.tellg();
710 inputFile.seekg(0, std::ios::end);
711 auto end = inputFile.tellg();
712
713 auto fileSize = end - begin;
714 if (fileSize == 0) {
715 return "";
716 }
717
718 // Read the file.
719 std::string result;
720 result.resize(fileSize);
721
722 inputFile.seekg(begin);
723 inputFile.read(result.data(), fileSize);
724 inputFile.close();
725 return result;
726}
727
728std::optional<std::string> generateFolderPath(
729 const char* basePath,

Callers 4

goMethod · 0.85
TEST_FFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

resizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45
closeMethod · 0.45

Tested by 3

TEST_FFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68