mirror of
https://github.com/AxioDL/nod.git
synced 2025-12-09 05:28:00 +00:00
Replace logvisor with spdlog
This commit is contained in:
12
lib/Util.cpp
12
lib/Util.cpp
@@ -1,4 +1,6 @@
|
||||
#include <nod/Util.hpp>
|
||||
#include "Util.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#if _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
@@ -31,7 +33,7 @@ FILE* Fopen(const char* path, const char* mode, FileLockType lock) {
|
||||
&ov);
|
||||
#else
|
||||
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
|
||||
LogModule.report(logvisor::Error, FMT_STRING("flock {}: {}"), path, strerror(errno));
|
||||
spdlog::error("flock {}: {}", path, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -46,21 +48,21 @@ bool CheckFreeSpace(const char* path, size_t reqSz) {
|
||||
wchar_t* end = nullptr;
|
||||
DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf.data(), &end);
|
||||
if (ret == 0 || ret > 1024) {
|
||||
LogModule.report(logvisor::Error, FMT_STRING("GetFullPathNameW {}"), path);
|
||||
spdlog::error("GetFullPathNameW {}", path);
|
||||
return false;
|
||||
}
|
||||
if (end != nullptr) {
|
||||
end[0] = L'\0';
|
||||
}
|
||||
if (!GetDiskFreeSpaceExW(buf.data(), &freeBytes, nullptr, nullptr)) {
|
||||
LogModule.report(logvisor::Error, FMT_STRING("GetDiskFreeSpaceExW {}: {}"), path, GetLastError());
|
||||
spdlog::error("GetDiskFreeSpaceExW {}: {}", path, GetLastError());
|
||||
return false;
|
||||
}
|
||||
return reqSz < freeBytes.QuadPart;
|
||||
#else
|
||||
struct statvfs svfs;
|
||||
if (statvfs(path, &svfs)) {
|
||||
LogModule.report(logvisor::Error, FMT_STRING("statvfs {}: {}"), path, strerror(errno));
|
||||
spdlog::error("statvfs {}: {}", path, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
return reqSz < svfs.f_frsize * svfs.f_bavail;
|
||||
|
||||
Reference in New Issue
Block a user