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

Method OpenFile

CodeFormatCore/src/Config/LuaEditorConfig.cpp:20–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#endif
19
20std::shared_ptr<LuaEditorConfig> LuaEditorConfig::OpenFile(const std::string &path) {
21 //FIX windows下读取中文路径
22#ifdef WIN32
23 std::fstream fin(utf8ToWideChar(path), std::ios::in | std::ios::binary);
24#else
25 std::fstream fin(path, std::ios::in | std::ios::binary);
26#endif
27 if (fin.is_open()) {
28 fin.seekg(0, std::ios::end);
29 auto size = fin.tellg();
30 std::string s(size, ' ');
31 fin.seekg(0);
32 fin.read(s.data(), size);
33 auto config = std::make_shared<LuaEditorConfig>();
34 config->Parse(s);
35 return config;
36 }
37
38 return nullptr;
39}
40
41static bool IsWhiteSpaces(int c) {
42 return c > 0 && std::isspace(c);

Callers

nothing calls this directly

Calls 4

utf8ToWideCharFunction · 0.85
is_openMethod · 0.45
dataMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected