forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CORE] OV file utils file_size use std file path (openvinotoolkit#28462)
### Details: - refactor file_size function to accept ov::util::Path / std::filesystem::path. Be backward compatible with previous version. ### Tickets: - [*146659*](https://jira.devtools.intel.com/browse/CVS-146659) --------- Co-authored-by: Michal Lukaszewski <[email protected]>
- Loading branch information
Showing
7 changed files
with
317 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/common/util/include/openvino/util/wstring_convert_util.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "openvino/util/util.hpp" | ||
|
||
namespace ov::util { | ||
|
||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT | ||
/** | ||
* @brief Conversion from wide character string to a single-byte chain. | ||
* @param wstr A wide-char string | ||
* @return A multi-byte string | ||
*/ | ||
std::string wstring_to_string(const std::wstring& wstr); | ||
/** | ||
* @brief Conversion from single-byte chain to wide character string. | ||
* @param str A null-terminated string | ||
* @return A wide-char string | ||
*/ | ||
std::wstring string_to_wstring(const std::string& str); | ||
|
||
#endif | ||
|
||
} // namespace ov::util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "openvino/util/file_path.hpp" | ||
|
||
#include "openvino/util/wstring_convert_util.hpp" | ||
|
||
#if defined(GCC_VER_LESS_THAN_12_3) || defined(CLANG_VER_LESS_THAN_17) | ||
|
||
template <> | ||
ov::util::Path::path(const std::wstring& source, ov::util::Path::format fmt) | ||
: path(ov::util::wstring_to_string(source), fmt) {} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "openvino/util/wstring_convert_util.hpp" | ||
|
||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT | ||
|
||
# include <codecvt> | ||
# include <locale> | ||
|
||
# ifdef _WIN32 | ||
# include <windows.h> | ||
# endif | ||
|
||
# ifdef __clang__ | ||
# pragma clang diagnostic push | ||
# pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
# endif | ||
|
||
std::string ov::util::wstring_to_string(const std::wstring& wstr) { | ||
# ifdef _WIN32 | ||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); | ||
std::string strTo(size_needed, 0); | ||
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); | ||
return strTo; | ||
# else | ||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wstring_decoder; | ||
return wstring_decoder.to_bytes(wstr); | ||
# endif | ||
} | ||
|
||
std::wstring ov::util::string_to_wstring(const std::string& string) { | ||
const char* str = string.c_str(); | ||
# ifdef _WIN32 | ||
int strSize = static_cast<int>(std::strlen(str)); | ||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, str, strSize, NULL, 0); | ||
std::wstring wstrTo(size_needed, 0); | ||
MultiByteToWideChar(CP_UTF8, 0, str, strSize, &wstrTo[0], size_needed); | ||
return wstrTo; | ||
# else | ||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wstring_encoder; | ||
std::wstring result = wstring_encoder.from_bytes(str); | ||
return result; | ||
# endif | ||
} | ||
|
||
# ifdef __clang__ | ||
# pragma clang diagnostic pop | ||
# endif | ||
|
||
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT |
Oops, something went wrong.