diff --git a/p2p/boost b/p2p/boost index da041154c..ad09f667e 160000 --- a/p2p/boost +++ b/p2p/boost @@ -1 +1 @@ -Subproject commit da041154c6bac1a4aa98254a7d6819059e8ac0b0 +Subproject commit ad09f667e61e18f5c31590941e748ac38e5a81bf diff --git a/p2p/source/load.cpp b/p2p/source/load.cpp index 8c7f42b5a..c0de53b0a 100644 --- a/p2p/source/load.cpp +++ b/p2p/source/load.cpp @@ -25,11 +25,11 @@ #include #endif +#include + #include #include -#include - #include "syscall.hpp" namespace orc { @@ -42,28 +42,37 @@ void Create(const std::string &path) { #endif } -void Delete(const std::string &file) { - orc_syscall(unlink(file.c_str())); +void Delete(const std::string &path) { + orc_syscall(unlink(path.c_str())); } bool Exists(const std::string &path) { return orc_syscall(access(path.c_str(), F_OK), ENOENT) == 0; } -uint64_t Modified(const std::string &file) { +uint64_t Modified(const std::string &path) { struct stat info{}; - orc_syscall(stat(file.c_str(), &info)); + orc_syscall(stat(path.c_str(), &info)); return info.st_mtime; } -std::string Load(const std::string &file) { orc_block({ +std::string Load(const std::string &path) { orc_block({ + std::ifstream file; + file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + file.open(path, std::ios::binary); + file.seekg(0, std::ios::end); std::string data; - boost::filesystem::load_string_file(file, data); + data.resize(file.tellg()); + file.seekg(0, std::ios::beg); + file.read(data.data(), data.size()); return data; -}, "loading from " << file); } - -void Save(const std::string &file, const std::string &data) { orc_block({ - boost::filesystem::save_string_file(file, data); -}, "saving to " << file); } +}, "loading from " << path); } + +void Save(const std::string &path, const std::string &data) { orc_block({ + std::ofstream file; + file.exceptions(std::ofstream::failbit | std::ofstream::badbit); + file.open(path, std::ios::binary); + file.write(data.data(), data.size()); +}, "saving to " << path); } } diff --git a/p2p/source/load.hpp b/p2p/source/load.hpp index 5d39f8ec1..59a1ed442 100644 --- a/p2p/source/load.hpp +++ b/p2p/source/load.hpp @@ -28,13 +28,13 @@ namespace orc { void Create(const std::string &path); -void Delete(const std::string &file); +void Delete(const std::string &path); bool Exists(const std::string &path); -uint64_t Modified(const std::string &file); +uint64_t Modified(const std::string &path); -std::string Load(const std::string &file); -void Save(const std::string &file, const std::string &data); +std::string Load(const std::string &path); +void Save(const std::string &path, const std::string &data); }