#pragma once #include "mcp_utils.h" #include #include #include #include "mcp_plugin_api.h" namespace mcp_utils { std::wstring utf8ToWString(const std::string &utf8Str) { return mcp_Tool_Utility::utf8ToWString(utf8Str); } std::string WStringToUtf8(const std::wstring &wstr) { return mcp_Tool_Utility::WStringToUtf8(wstr); } bool mcp_utils::hasFileExist(const std::wstring &filePath) { return _taccess(filePath.c_str(), 0) == 0; } bool mcp_utils::hasDirExist(const std::wstring &filePath) { return _taccess(filePath.c_str(), 0) == 0; } std::wstring getModelDir() { TCHAR szPath[MAX_PATH]; ::GetModuleFileName(_hdllInstance, szPath, MAX_PATH); ghc::filesystem::path path(szPath); return path.parent_path().wstring(); } fs::path getModelDirPath() { return fs::path(getModelDir()); } fs::path relative2absolute(const std::string &relativePath, const fs::path &rootPath) { return relative2absolute(fs::path(utf8ToWString(relativePath)), rootPath); } fs::path relative2absolute(const fs::path &relativePath, const fs::path &rootPath) { fs::path absolutePath = rootPath / relativePath; return absolutePath.lexically_normal().wstring(); } }