MCPcopy Create free account
hub / github.com/78/tenbox / WriteFileAtomic

Function WriteFileAtomic

src/daemon/host_settings.cpp:14–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12constexpr const char* kHostSettingsFile = "host_settings.json";
13
14bool WriteFileAtomic(const fs::path& target, const std::string& contents) {
15 fs::path tmp = target;
16 tmp += ".tmp";
17 std::error_code ec;
18 fs::create_directories(target.parent_path(), ec);
19 {
20 std::ofstream out(tmp, std::ios::binary | std::ios::trunc);
21 if (!out) return false;
22 out.write(contents.data(), static_cast<std::streamsize>(contents.size()));
23 if (!out) return false;
24 }
25 fs::rename(tmp, target, ec);
26 if (ec) {
27 fs::remove(tmp, ec);
28 return false;
29 }
30 return true;
31}
32} // namespace
33
34nlohmann::json ToJson(const LlmModelMapping& mapping) {

Callers 1

SaveHostSettingsFunction · 0.70

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected