MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / ReadFile

Function ReadFile

CodeFormat/src/Util.cpp:6–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6std::optional<std::string> ReadFile(std::string_view path) {
7 std::string newPath(path);
8#ifdef _WIN32
9 std::fstream fin(newPath, std::ios::in | std::ios::binary);
10#else
11 std::fstream fin(newPath, std::ios::in);
12#endif
13
14 if (fin.is_open()) {
15 std::stringstream s;
16 s << fin.rdbuf();
17 return std::move(s.str());
18 }
19
20 return std::nullopt;
21}

Callers 5

CheckWorkspaceMethod · 0.85
ReformatWorkspaceMethod · 0.85
GetInputTextMethod · 0.85
TESTFunction · 0.85

Calls 3

rdbufMethod · 0.80
strMethod · 0.80
is_openMethod · 0.45

Tested by 1

TESTFunction · 0.68