MCPcopy Create free account
hub / github.com/Samsung/UTopia / readFile

Function readFile

lib/utils/FileUtil.cpp:78–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78std::string readFile(const char *filePath) {
79 std::ifstream inputFile(filePath);
80 std::string fileContext;
81 if (inputFile.is_open()) {
82 inputFile.seekg(0, std::ios::end);
83 int fileSize = inputFile.tellg();
84 fileContext.resize(fileSize);
85 inputFile.seekg(0, std::ios::beg);
86 inputFile.read(&fileContext[0], fileSize);
87 inputFile >> fileContext;
88
89 std::cerr << "file opened: " << filePath << std::endl;
90 return fileContext;
91 } else {
92 std::cerr << "Failed Open File: " << filePath << std::endl;
93 return "";
94 }
95}
96
97std::vector<std::string> readDirectory(const std::string &dirPath) {
98 std::vector<std::string> fileList;

Callers 4

parseJsonFileToJsonValueFunction · 0.85
loadTargetMethod · 0.85
loadExternalsMethod · 0.85
TESTFunction · 0.85

Calls 1

resizeMethod · 0.80

Tested by 1

TESTFunction · 0.68