This commit is contained in:
2025-12-18 00:07:04 -05:00
parent e81030d9e3
commit 6257e7dffb
2 changed files with 42 additions and 2 deletions

View File

@@ -154,9 +154,19 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl
dest = (val == "true" || val == "1"); dest = (val == "true" || val == "1");
} }
else if constexpr (std::is_same_v<T, std::string>) else if constexpr (std::is_same_v<T, std::string>)
{
std::getline(ss, dest); std::getline(ss, dest);
}
else if constexpr (std::is_same_v<T, std::filesystem::path>)
{
std::string value;
std::getline(ss, value);
dest = path::from_utf8(value);
}
else else
{
stream_assign(dest, ss); stream_assign(dest, ss);
}
}; };
auto entry_load = auto entry_load =
@@ -324,6 +334,8 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl
if constexpr (std::is_same_v<T, bool>) if constexpr (std::is_same_v<T, bool>)
file << key << "=" << (value ? "true" : "false") << "\n"; file << key << "=" << (value ? "true" : "false") << "\n";
else if constexpr (std::is_same_v<T, std::filesystem::path>)
file << key << "=" << path::to_utf8(value) << "\n";
else else
file << key << "=" << value << "\n"; file << key << "=" << value << "\n";
}; };

View File

@@ -1,7 +1,33 @@
#include "process_.h" #include "process_.h"
#ifdef WIN32
#include <cstddef>
#include <string>
#include <windows.h>
#endif
namespace anm2ed::util namespace anm2ed::util
{ {
#ifdef WIN32
namespace
{
std::wstring utf8_to_wstring(const char* string)
{
if (!string) return {};
auto requiredSize = MultiByteToWideChar(CP_UTF8, 0, string, -1, nullptr, 0);
if (requiredSize <= 0) return {};
std::wstring wide(static_cast<std::size_t>(requiredSize), L'\0');
MultiByteToWideChar(CP_UTF8, 0, string, -1, wide.data(), requiredSize);
if (!wide.empty() && wide.back() == L'\0') wide.pop_back();
return wide;
}
}
#endif
Process::Process(const char* command, const char* mode) { open(command, mode); } Process::Process(const char* command, const char* mode) { open(command, mode); }
Process::~Process() { close(); } Process::~Process() { close(); }
@@ -11,7 +37,9 @@ namespace anm2ed::util
close(); close();
#ifdef WIN32 #ifdef WIN32
pipe = _popen(command, mode); auto wideCommand = utf8_to_wstring(command);
auto wideMode = utf8_to_wstring(mode);
pipe = _wpopen(wideCommand.c_str(), wideMode.c_str());
#else #else
pipe = popen(command, mode); pipe = popen(command, mode);
#endif #endif
@@ -52,4 +80,4 @@ namespace anm2ed::util
FILE* Process::get() const { return pipe; } FILE* Process::get() const { return pipe; }
Process::operator bool() const { return pipe != nullptr; } Process::operator bool() const { return pipe != nullptr; }
} }