MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / safe_write_file

Function safe_write_file

common/hf-cache.cpp:177–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177static void safe_write_file(const fs::path & path, const std::string & data) {
178 fs::path path_tmp = path.string() + ".tmp";
179
180 if (path.has_parent_path()) {
181 fs::create_directories(path.parent_path());
182 }
183
184 std::ofstream file(path_tmp);
185 file << data;
186 file.close();
187
188 std::error_code ec;
189
190 if (!file.fail()) {
191 fs::rename(path_tmp, path, ec);
192 }
193 if (file.fail() || ec) {
194 fs::remove(path_tmp, ec);
195 throw std::runtime_error("failed to write file: " + path.string());
196 }
197}
198
199static nl::json api_get(const std::string & url,
200 const std::string & token) {

Callers 1

get_repo_commitFunction · 0.85

Calls 3

failMethod · 0.80
stringMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected