Deprecate usage of some functions in boost (#130)
Some checks failed
Build / build (push) Has been cancelled

* Deprecate usage of boost::filesystem::load_string_file and save_string_file

* some other deperated functions

* remove complete()

* normal, save, load
This commit is contained in:
Symious
2025-03-08 21:03:15 +08:00
committed by GitHub
parent 923bdd7c66
commit 3b273a6de2
5 changed files with 38 additions and 17 deletions

View File

@@ -1,12 +1,15 @@
#include "FileUtils.h"
#include <boost/filesystem/string_file.hpp>
#include <fstream>
namespace hf3fs {
Result<std::string> loadFile(const Path &path) {
try {
std::string output;
boost::filesystem::load_string_file(path, output);
std::ifstream file(path);
if (!file) {
return makeError(StatusCode::kIOError, fmt::format("Error opening file: {}", path));
}
std::string output((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
return output;
} catch (const std::exception &e) {
return makeError(StatusCode::kIOError, fmt::format("Error when read {}: {}", path, e.what()));
@@ -15,7 +18,15 @@ Result<std::string> loadFile(const Path &path) {
Result<Void> storeToFile(const Path &path, const std::string &content) {
try {
boost::filesystem::save_string_file(path, content);
std::ofstream file(path);
if (!file) {
return makeError(StatusCode::kIOError, fmt::format("Error opening file for writing: {}", path));
}
file << content;
if (!file) {
return makeError(StatusCode::kIOError, fmt::format("Error writing to file: {}", path));
}
return Void{};
} catch (const std::exception &e) {
return makeError(StatusCode::kIOError, fmt::format("Error when write to {}: {}", path, e.what()));

View File

@@ -2150,7 +2150,7 @@ void hf3fs_ioctl(fuse_req_t req,
fuse_reply_err(req, EINVAL);
return;
}
if (name.has_branch_path()) {
if (name.has_parent_path()) {
fuse_reply_err(req, EINVAL);
return;
}