| 18 | #endif |
| 19 | |
| 20 | std::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 | |
| 41 | static bool IsWhiteSpaces(int c) { |
| 42 | return c > 0 && std::isspace(c); |
nothing calls this directly
no test coverage detected