Fix compile errors/typos; update logvisor

This commit is contained in:
Luke Street 2021-06-30 16:22:50 -04:00
parent c1635245b8
commit 0985c63958
5 changed files with 18 additions and 7 deletions

View File

@ -1,11 +1,15 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { #include <array>
#define OS_CONSTEXPR constexpr #define OS_CONSTEXPR constexpr
extern "C" {
#else #else
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#define OS_CONSTEXPR #define OS_CONSTEXPR
typedef uint8_t char8_t; typedef uint8_t char8_t;
typedef uint16_t char16_t; typedef uint16_t char16_t;
typedef uint32_t char32_t; typedef uint32_t char32_t;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#if _WIN32 && UNICODE #if _WIN32
#include <array>
#include <cwctype> #include <cwctype>
#include <direct.h> #include <direct.h>
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@ -88,7 +89,7 @@ static inline int Stat(const char* path, Sstat* statout) {
return _wstat64(wpath.get(), statout); return _wstat64(wpath.get(), statout);
} }
#else #else
static inline int Mkdir(const char* path, mode_t mode) { return CreateDirectoryA(path, mode); } static inline int Mkdir(const char* path, mode_t mode) { return mkdir(path, mode); }
typedef struct stat Sstat; typedef struct stat Sstat;
static inline int Stat(const char* path, Sstat* statout) { return stat(path, statout); } static inline int Stat(const char* path, Sstat* statout) { return stat(path, statout); }
@ -235,14 +236,14 @@ static inline bool CheckFreeSpace(const char* path, size_t reqSz) {
wchar_t* end = nullptr; wchar_t* end = nullptr;
DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf.data(), &end); DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf.data(), &end);
if (ret == 0 || ret > 1024) { if (ret == 0 || ret > 1024) {
LogModule.report(logvisor::Error, FMT_STRING("GetFullPathNameA {}"), path); LogModule.report(logvisor::Error, FMT_STRING("GetFullPathNameW {}"), path);
return false; return false;
} }
if (end != nullptr) { if (end != nullptr) {
end[0] = L'\0'; end[0] = L'\0';
} }
if (!GetDiskFreeSpaceExW(buf.data(), &freeBytes, nullptr, nullptr)) { if (!GetDiskFreeSpaceExW(buf.data(), &freeBytes, nullptr, nullptr)) {
LogModule.report(logvisor::Error, FMT_STRING("GetDiskFreeSpaceExA {}: {}"), path, GetLastError()); LogModule.report(logvisor::Error, FMT_STRING("GetDiskFreeSpaceExW {}: {}"), path, GetLastError());
return false; return false;
} }
return reqSz < freeBytes.QuadPart; return reqSz < freeBytes.QuadPart;

View File

@ -1,15 +1,20 @@
#include "nod/DirectoryEnumerator.hpp" #include "nod/DirectoryEnumerator.hpp"
#ifdef _WIN32 #ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h> #include <windows.h>
#else #else
#include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h>
#endif #endif
#include <cstring> #include <cstring>
#include <map> #include <map>
#ifdef __cpp_lib_ranges
#include <ranges> #include <ranges>
#endif
namespace nod { namespace nod {

View File

@ -1,6 +1,7 @@
#include "nod/OSUTF.h" #include "nod/OSUTF.h"
#include <assert.h> #include <assert.h>
#include <stddef.h>
static const char16_t Sjis00[256] = { static const char16_t Sjis00[256] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,

@ -1 +1 @@
Subproject commit df3c283186a677d178b61240003ec4114e9a925b Subproject commit 4f7f3f2147827715e685321874081a0a6683b0af