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

Method readSqlFromFile

bolt/expression/tests/ExprTest.cpp:307–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 }
306
307 std::string readSqlFromFile(const std::string& path) {
308 std::ifstream inputFile(path, std::ifstream::binary);
309
310 // Find out file size.
311 auto begin = inputFile.tellg();
312 inputFile.seekg(0, std::ios::end);
313 auto end = inputFile.tellg();
314
315 auto fileSize = end - begin;
316 if (fileSize == 0) {
317 return "";
318 }
319
320 // Read the file.
321 std::string sql;
322 sql.resize(fileSize);
323
324 inputFile.seekg(begin);
325 inputFile.read(sql.data(), fileSize);
326 inputFile.close();
327 return sql;
328 }
329
330 std::exception_ptr assertError(
331 const std::string& expression,

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected