mirror of https://github.com/AxioDL/nod.git
Windows refactors
This commit is contained in:
parent
83b96b1bc2
commit
23a536a2b1
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(NODLib)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
|
||||
|
|
2
LogVisor
2
LogVisor
|
@ -1 +1 @@
|
|||
Subproject commit 154b84413050cdb03f281c42861b9af6eaef7d14
|
||||
Subproject commit 828db515ba316903c367b9dc7acf9d0bec0969e7
|
|
@ -139,7 +139,7 @@ public:
|
|||
p->wbfs_sec_sz = 1<<p->wbfs_sec_sz_s;
|
||||
p->n_wbfs_sec = p->n_wii_sec >> (p->wbfs_sec_sz_s - p->wii_sec_sz_s);
|
||||
p->n_wbfs_sec_per_disc = p->n_wii_sec_per_disc >> (p->wbfs_sec_sz_s - p->wii_sec_sz_s);
|
||||
p->disc_info_sz = ALIGN_LBA(sizeof(WBFSDiscInfo) + p->n_wbfs_sec_per_disc*2);
|
||||
p->disc_info_sz = ALIGN_LBA(uint16_t(sizeof(WBFSDiscInfo)) + p->n_wbfs_sec_per_disc*2);
|
||||
|
||||
p->freeblks_lba = (p->wbfs_sec_sz - p->n_wbfs_sec/8)>>p->hd_sec_sz_s;
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include "NOD/NOD.hpp"
|
||||
|
||||
namespace NOD
|
||||
|
@ -5,29 +9,45 @@ namespace NOD
|
|||
|
||||
std::string WideToUTF8(const std::wstring& src)
|
||||
{
|
||||
#if _WIN32
|
||||
int len = WideCharToMultiByte(CP_UTF8, 0, src.c_str(), src.size(), nullptr, 0, nullptr, nullptr);
|
||||
std::string retval(len, '\0');
|
||||
WideCharToMultiByte(CP_UTF8, 0, src.c_str(), src.size(), &retval[0], len, nullptr, nullptr);
|
||||
return retval;
|
||||
#else
|
||||
std::string retval;
|
||||
retval.reserve(src.length());
|
||||
std::mbstate_t state = {};
|
||||
for (wchar_t ch : src)
|
||||
{
|
||||
char mb[4];
|
||||
int c = std::wctomb(mb, ch);
|
||||
char mb[MB_LEN_MAX];
|
||||
int c = std::wcrtomb(mb, ch, &state);
|
||||
retval.append(mb, c);
|
||||
}
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring UTF8ToWide(const std::string& src)
|
||||
{
|
||||
#if _WIN32
|
||||
int len = MultiByteToWideChar(CP_UTF8, 0, src.c_str(), src.size(), nullptr, 0);
|
||||
std::wstring retval(len, L'\0');
|
||||
MultiByteToWideChar(CP_UTF8, 0, src.c_str(), src.size(), &retval[0], len);
|
||||
return retval;
|
||||
#else
|
||||
std::wstring retval;
|
||||
retval.reserve(src.length());
|
||||
const char* buf = src.c_str();
|
||||
std::mbstate_t state = {};
|
||||
while (*buf)
|
||||
{
|
||||
wchar_t wc;
|
||||
buf += std::mbtowc(&wc, buf, MB_CUR_MAX);
|
||||
buf += std::mbrtowc(&wc, buf, MB_LEN_MAX, &state);
|
||||
retval += wc;
|
||||
}
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue