Remove unused graph manager file helpers
This commit is contained in:
parent
7b9d1aa385
commit
72d6a073a0
@ -1,6 +1,5 @@
|
||||
#include "graph_manager.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
@ -12,11 +11,6 @@
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
|
||||
#include "utils/config_expand.h"
|
||||
#include "utils/config_schema.h"
|
||||
#include "utils/logger.h"
|
||||
@ -74,41 +68,6 @@ std::string AffinityKey(std::vector<int> cpus) {
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
bool WriteTextFile(const std::string& path, const std::string& content, std::string& err) {
|
||||
std::ofstream ofs(path, std::ios::binary | std::ios::trunc);
|
||||
if (!ofs.is_open()) {
|
||||
err = "Failed to open file for write: " + path;
|
||||
return false;
|
||||
}
|
||||
ofs.write(content.data(), static_cast<std::streamsize>(content.size()));
|
||||
if (!ofs.good()) {
|
||||
err = "Failed to write file: " + path;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteTextFileAtomic(const std::string& path, const std::string& content, std::string& err) {
|
||||
err.clear();
|
||||
#if __has_include(<filesystem>)
|
||||
const std::string tmp = path + ".tmp";
|
||||
if (!WriteTextFile(tmp, content, err)) return false;
|
||||
std::error_code ec;
|
||||
fs::remove(path, ec); // best-effort (Windows rename requires target missing)
|
||||
ec.clear();
|
||||
fs::rename(tmp, path, ec);
|
||||
if (ec) {
|
||||
err = "rename failed: " + ec.message();
|
||||
std::error_code ec2;
|
||||
fs::remove(tmp, ec2);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
return WriteTextFile(path, content, err);
|
||||
#endif
|
||||
}
|
||||
|
||||
QueueDropStrategy ParseDropStrategy(const std::string& s, QueueDropStrategy def) {
|
||||
if (s == "drop_oldest") return QueueDropStrategy::DropOldest;
|
||||
if (s == "drop_newest") return QueueDropStrategy::DropNewest;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user