MCPcopy Create free account
hub / github.com/build-cpp/cmkr / read_file

Function read_file

src/cmake_generator.cpp:161–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static std::string read_file(const fs::path &path) {
162 std::ifstream ifs(path, std::ios::binary);
163 if (!ifs) {
164 throw std::runtime_error("Failed to read " + path.string());
165 }
166 std::string contents;
167 ifs.seekg(0, std::ios::end);
168 contents.resize(ifs.tellg());
169 ifs.seekg(0, std::ios::beg);
170 ifs.read(&contents[0], contents.size());
171 return contents;
172}
173
174// CMake target name rules: https://cmake.org/cmake/help/latest/policy/CMP0037.html [A-Za-z0-9_.+\-]
175// TOML bare keys: non-empty strings composed only of [A-Za-z0-9_-]

Callers 1

generate_gitfileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected