mirror of https://github.com/oxen-io/lokinet
RouterContact::[Read|Write] now take a fs::path const ref
This commit is contained in:
parent
f62214cf8c
commit
5529371637
|
@ -20,7 +20,6 @@ if($ENV{COMPILER} MATCHES "clang")
|
|||
else()
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
add_compile_options("-Wa,-mbig-obj")
|
||||
endif()
|
||||
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
|
|
|
@ -216,7 +216,7 @@ main(int argc, char* argv[])
|
|||
{
|
||||
llarp::ensureConfig(
|
||||
llarp::GetDefaultDataDir(), llarp::GetDefaultConfigPath(), overwrite, opts.isRelay);
|
||||
conffname = llarp::GetDefaultConfigPath().string().c_str();
|
||||
conffname = llarp::GetDefaultConfigPath().string();
|
||||
}
|
||||
|
||||
if (genconfigOnly)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace llarp
|
|||
m_lokidRPCPassword = config.lokid.lokidRPCPassword;
|
||||
|
||||
RouterContact rc;
|
||||
bool exists = rc.Read(m_rcPath.string().c_str());
|
||||
bool exists = rc.Read(m_rcPath);
|
||||
if (not exists and not genIfAbsent)
|
||||
{
|
||||
LogError("Could not read RouterContact at path ", m_rcPath);
|
||||
|
|
|
@ -299,14 +299,14 @@ llarp_nodedb::loadfile(const fs::path& fpath)
|
|||
if (fpath.extension() != RC_FILE_EXT)
|
||||
return false;
|
||||
llarp::RouterContact rc;
|
||||
if (!rc.Read(fpath.string().c_str()))
|
||||
if (!rc.Read(fpath))
|
||||
{
|
||||
llarp::LogError("failed to read file ", fpath);
|
||||
llarp::LogError("failed to read file ", fpath.string());
|
||||
return false;
|
||||
}
|
||||
if (!rc.Verify(llarp::time_now_ms()))
|
||||
{
|
||||
llarp::LogError(fpath, " contains invalid RC");
|
||||
llarp::LogError(fpath.string(), " contains invalid RC");
|
||||
return false;
|
||||
}
|
||||
{
|
||||
|
|
|
@ -379,7 +379,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
RouterContact::Write(const char* fname) const
|
||||
RouterContact::Write(const fs::path& fname) const
|
||||
{
|
||||
std::array<byte_t, MAX_RC_SIZE> tmp;
|
||||
llarp_buffer_t buf(tmp);
|
||||
|
@ -389,8 +389,7 @@ namespace llarp
|
|||
}
|
||||
buf.sz = buf.cur - buf.base;
|
||||
buf.cur = buf.base;
|
||||
const fs::path fpath = std::string(fname); /* */
|
||||
auto f = llarp::util::OpenFileStream<std::ofstream>(fpath, std::ios::binary);
|
||||
auto f = llarp::util::OpenFileStream<std::ofstream>(fname, std::ios::binary);
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
|
@ -404,12 +403,12 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
RouterContact::Read(const char* fname)
|
||||
RouterContact::Read(const fs::path& fname)
|
||||
{
|
||||
std::array<byte_t, MAX_RC_SIZE> tmp;
|
||||
llarp_buffer_t buf(tmp);
|
||||
std::ifstream f;
|
||||
f.open(fname, std::ios::binary);
|
||||
f.open(fname.string(), std::ios::binary);
|
||||
if (!f.is_open())
|
||||
{
|
||||
llarp::LogError("Failed to open ", fname);
|
||||
|
|
|
@ -208,10 +208,10 @@ namespace llarp
|
|||
print(std::ostream& stream, int level, int spaces) const;
|
||||
|
||||
bool
|
||||
Read(const char* fname);
|
||||
Read(const fs::path& fname);
|
||||
|
||||
bool
|
||||
Write(const char* fname) const;
|
||||
Write(const fs::path& fname) const;
|
||||
|
||||
bool
|
||||
VerifySignature() const;
|
||||
|
|
Loading…
Reference in New Issue