gormf
This commit is contained in:
@@ -154,9 +154,19 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1902,994 Spl
|
||||
dest = (val == "true" || val == "1");
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
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
|
||||
{
|
||||
stream_assign(dest, ss);
|
||||
}
|
||||
};
|
||||
|
||||
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>)
|
||||
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
|
||||
file << key << "=" << value << "\n";
|
||||
};
|
||||
|
||||
+30
-2
@@ -1,7 +1,33 @@
|
||||
#include "process_.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
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() { close(); }
|
||||
@@ -11,7 +37,9 @@ namespace anm2ed::util
|
||||
close();
|
||||
|
||||
#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
|
||||
pipe = popen(command, mode);
|
||||
#endif
|
||||
@@ -52,4 +80,4 @@ namespace anm2ed::util
|
||||
FILE* Process::get() const { return pipe; }
|
||||
|
||||
Process::operator bool() const { return pipe != nullptr; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user