fix: change code to suit for new YYCC library
This commit is contained in:
@@ -86,21 +86,21 @@ namespace VSW::Materializer {
|
||||
auto& config_manager = PluginMain::ConfigManager::GetSingleton();
|
||||
auto u8_last_path = config_manager.m_LastFilePath.Get();
|
||||
if (!u8_last_path.empty()) {
|
||||
auto last_path = YYCC::FsPathPatch::FromUTF8Path(u8_last_path.c_str());
|
||||
auto last_path = YYCC::StdPatch::ToStdPath(u8_last_path);
|
||||
switch (m_InitialDatabaseType) {
|
||||
case InitialDatabaseType::Script:
|
||||
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("script.db")));
|
||||
last_path.replace_filename(YYCC::StdPatch::ToStdPath(YYCC_U8("script.db")));
|
||||
break;
|
||||
case InitialDatabaseType::Document:
|
||||
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("doc.db")));
|
||||
last_path.replace_filename(YYCC::StdPatch::ToStdPath(YYCC_U8("doc.db")));
|
||||
break;
|
||||
case InitialDatabaseType::Environment:
|
||||
last_path.replace_filename(YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("env.db")));
|
||||
last_path.replace_filename(YYCC::StdPatch::ToStdPath(YYCC_U8("env.db")));
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("invalid initial database type");
|
||||
}
|
||||
u8_last_path = YYCC::FsPathPatch::ToUTF8Path(last_path);
|
||||
u8_last_path = YYCC::StdPatch::ToUTF8Path(last_path);
|
||||
}
|
||||
PushDatabaseFile(u8_last_path);
|
||||
PushEncoding(config_manager.m_Encoding.Get());
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace VSW::Materializer::PluginMain {
|
||||
if (!YYCC::WinFctHelper::GetModuleFileName(NULL, u8_virtools_path))
|
||||
u8_virtools_path.clear();
|
||||
// get its parent folder and append with cfg file name
|
||||
std::filesystem::path virtools_path(YYCC::FsPathPatch::FromUTF8Path(u8_virtools_path.c_str()));
|
||||
return YYCC::FsPathPatch::ToUTF8Path(virtools_path.parent_path() / YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("vsw_materializer.cfg")));
|
||||
std::filesystem::path virtools_path(YYCC::StdPatch::ToStdPath(u8_virtools_path));
|
||||
return YYCC::StdPatch::ToUTF8Path(virtools_path.parent_path() / YYCC::StdPatch::ToStdPath(YYCC_U8("vsw_materializer.cfg")));
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -119,24 +119,19 @@ namespace VSW::Materializer::StandaloneMain {
|
||||
if (u8_vt_file.empty()) throw std::invalid_argument("Invalid Virtools file path");
|
||||
|
||||
// build source virtools file
|
||||
auto vt_file = YYCC::FsPathPatch::FromUTF8Path(u8_vt_file.data());
|
||||
auto vt_file = YYCC::StdPatch::ToStdPath(u8_vt_file);
|
||||
|
||||
// build cache path located in Windows temp path and keep its extension
|
||||
YYCC::yycc_u8string u8_temp_dir;
|
||||
if (!YYCC::WinFctHelper::GetTempDirectory(u8_temp_dir))
|
||||
throw std::runtime_error("Fail to fetch Windows Temp directory");
|
||||
auto temp_dir = YYCC::FsPathPatch::FromUTF8Path(u8_temp_dir.c_str());
|
||||
temp_dir /= YYCC::FsPathPatch::FromUTF8Path(YYCC_U8("07159749-81e5-4ec2-b649-87b8eb9c1f5a"));
|
||||
auto temp_dir = YYCC::StdPatch::ToStdPath(u8_temp_dir);
|
||||
temp_dir /= YYCC::StdPatch::ToStdPath(YYCC_U8("07159749-81e5-4ec2-b649-87b8eb9c1f5a"));
|
||||
temp_dir.replace_extension(vt_file.extension());
|
||||
m_TempFile = YYCC::FsPathPatch::ToUTF8Path(temp_dir);
|
||||
m_TempFile = YYCC::StdPatch::ToUTF8Path(temp_dir);
|
||||
|
||||
// copy it to temp directory
|
||||
std::wstring w_temp_file, w_vt_file;
|
||||
if (!YYCC::EncodingHelper::UTF8ToWchar(u8_vt_file, w_vt_file))
|
||||
throw std::runtime_error("Fail to fetch source file.");
|
||||
if (!YYCC::EncodingHelper::UTF8ToWchar(m_TempFile, w_temp_file))
|
||||
throw std::runtime_error("Fail to fetch temporary file.");
|
||||
if (!::CopyFileW(w_vt_file.c_str(), w_temp_file.c_str(), FALSE))
|
||||
if (!YYCC::WinFctHelper::CopyFile(u8_vt_file, m_TempFile, FALSE))
|
||||
throw std::runtime_error("Fail to copy file.");
|
||||
|
||||
// okey
|
||||
|
||||
@@ -122,8 +122,8 @@ namespace VSW::Materializer::Utilities {
|
||||
return;
|
||||
}
|
||||
// Then get its file name part
|
||||
auto module_path = YYCC::FsPathPatch::FromUTF8Path(u8_module_path.c_str());
|
||||
auto u8_module_name = YYCC::FsPathPatch::ToUTF8Path(module_path.filename());
|
||||
auto module_path = YYCC::StdPatch::ToStdPath(u8_module_path);
|
||||
auto u8_module_name = YYCC::StdPatch::ToUTF8Path(module_path.filename());
|
||||
|
||||
// Get the base address of current module
|
||||
// HMODULE is the base address of loaded module
|
||||
|
||||
Reference in New Issue
Block a user