| 53 | } |
| 54 | |
| 55 | std::optional<STDString> LoadExternalFile(std::string_view path, PathRootType root) |
| 56 | { |
| 57 | if (!IsSafeRelativePath(STDString(path))) { |
| 58 | return {}; |
| 59 | } |
| 60 | |
| 61 | if (root == PathRootType::Data) { |
| 62 | auto reader = GetStaticSymbols().MakeFileReader(path, root); |
| 63 | if (reader.IsLoaded()) { |
| 64 | return reader.ToString(); |
| 65 | } |
| 66 | } else { |
| 67 | auto absolutePath = GetPathForExternalIo(path, root); |
| 68 | if (!absolutePath) return {}; |
| 69 | |
| 70 | std::ifstream f(absolutePath->c_str(), std::ios::in | std::ios::binary); |
| 71 | if (f.good()) { |
| 72 | STDString body; |
| 73 | f.seekg(0, std::ios::end); |
| 74 | body.resize((unsigned)f.tellg()); |
| 75 | f.seekg(0, std::ios::beg); |
| 76 | f.read(body.data(), body.size()); |
| 77 | return body; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | return {}; |
| 82 | } |
| 83 | |
| 84 | bool CreateParentDirectoryRecursive(std::wstring_view path) |
| 85 | { |
no test coverage detected