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