Skip to content

Commit

Permalink
Upgrade boost to fix a silly unused variable lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Feb 26, 2024
1 parent c0d3629 commit 1c5b19d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion p2p/boost
Submodule boost updated 136 files
35 changes: 22 additions & 13 deletions p2p/source/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include <winsock2.h>
#endif

#include <fstream>

#include <sys/stat.h>
#include <sys/types.h>

#include <boost/filesystem/string_file.hpp>

#include "syscall.hpp"

namespace orc {
Expand All @@ -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); }

}
8 changes: 4 additions & 4 deletions p2p/source/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down

0 comments on commit 1c5b19d

Please sign in to comment.