Warning, file /include/onnx/common/path.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <string>
0010 #ifdef _WIN32
0011 #include <windows.h>
0012
0013 #include <filesystem>
0014
0015 #include "onnx/checker.h"
0016 #endif
0017
0018 namespace ONNX_NAMESPACE {
0019
0020 #ifdef _WIN32
0021 constexpr const char k_preferred_path_separator = '\\';
0022 #else
0023 constexpr const char k_preferred_path_separator = '/';
0024 #endif
0025
0026 #ifdef _WIN32
0027 inline std::wstring path_join(const std::wstring& origin, const std::wstring& append) {
0028 return (std::filesystem::path(origin) / std::filesystem::path(append)).wstring();
0029 }
0030 inline std::wstring utf8str_to_wstring(const std::string& utf8str) {
0031 if (utf8str.size() > INT_MAX) {
0032 fail_check("utf8str_to_wstring: string is too long for converting to wstring.");
0033 }
0034 int size_required = MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), (int)utf8str.size(), NULL, 0);
0035 std::wstring ws_str(size_required, 0);
0036 MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), (int)utf8str.size(), &ws_str[0], size_required);
0037 return ws_str;
0038 }
0039
0040 #else
0041 std::string path_join(const std::string& origin, const std::string& append);
0042
0043
0044
0045 std::string clean_relative_path(const std::string& path);
0046 #endif
0047
0048 }