-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[CORE] OV file utils file_size use std file path #28462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mlukasze
merged 59 commits into
openvinotoolkit:master
from
barnasm1:ov_file_path_util_file_size
Feb 5, 2025
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
887dd2b
move wide character string conversions to separate file
barnasm1 04671c7
refactor
barnasm1 b334528
refactor file size functions to use ov::util::Path and handle Android…
barnasm1 c0ec93e
add unit tests for cut_android_path function
barnasm1 dce5d59
add unit tests for file size functions with various file types and en…
barnasm1 701cd96
code format
barnasm1 97f2a96
prevent variable redefinition for android
barnasm1 c0345b1
refactor test to use ov::util::Path for Unicode file output
barnasm1 66615dc
Merge branch 'master' into ov_file_path_util_file_size
mlukasze a1e8053
add Windows-specific includes for wstring_cast_util
barnasm1 f34b2d2
fix comment typo
barnasm1 2d071bf
refactor cpp_version.hpp and file_path.hpp for compiler version checks
barnasm1 3b2fbae
refactor WPath function to use lambda syntax, to meet Naming style check
barnasm1 eed127e
update copyright year to 2025, fix typos,
barnasm1 067224b
rename wstring_cast_util to wstring_convert_util and update includes
barnasm1 22d6712
add Android-specific file size test
barnasm1 2e7cf52
fix typo in CMakeLists.txt for wstring_convert_util source file path
barnasm1 e9c2cca
deprecate old file_size function and provide alternative usage guidance
barnasm1 71e2206
update file size tests to use string literals
barnasm1 c8bdb3b
skip file size tests based on C++ version
barnasm1 dd13c04
revert: refactor WPath function to use lambda syntax, to meet Naming …
barnasm1 74640d8
Merge branch 'master' into ov_file_path_util_file_size
barnasm1 0f2aa4a
clang format
barnasm1 76d0a49
Merge branch 'master' into ov_file_path_util_file_size
barnasm1 f9cd47d
Merge branch 'master' into ov_file_path_util_file_size
barnasm1 0794bcd
Refactor namespace declaration
barnasm1 8d745c5
Replace file size calculation with std::filesystem
barnasm1 a82aef0
Refactor cut_android_path function for improved readability
barnasm1 77dd50f
Remove deprecated file_size function
barnasm1 d45867d
Update file_size function to use ov::util namespace for consistency
barnasm1 8837c2e
Refactor file path handling and update file size functions
barnasm1 d9a9487
Revert "Remove deprecated file_size function"
barnasm1 6c8b9a5
Fix preprocessor directive formatting for GCC and Clang version checks
barnasm1 8acae29
Fix file_size function to handle Android paths correctly
barnasm1 b45c26b
Update file size tests to use string literals to avoid deprecation wa…
barnasm1 65cc6d5
Add Unicode content tests for file size functionality
barnasm1 bab5a77
Add test for file size calculation of raw byte files
barnasm1 b8cf8dc
Remove Unicode content tests and related setup from FileUtilTest
barnasm1 f4cb551
cut_android_path function restrict
barnasm1 feab0bd
check if cut_android_path is required at new impl
barnasm1 07f5a1b
Refactor file size and clean up unused includes
barnasm1 3c90e81
Update file_size function to accept std::wstring and adjust related t…
barnasm1 664b578
Remove deprecated file_size function for std::wstring and update path…
barnasm1 3227347
Simplify file_size function implementation
barnasm1 b0f211c
Update test to avoid filesize discrepancies of std::endl platforms en…
barnasm1 b28d093
Merge branch 'master' into ov_file_path_util_file_size
mlukasze b9b1a56
Deprecate old file_size function and update tests
barnasm1 afacbb0
Remove string literal suffixes from file_size test cases
barnasm1 99a18fb
Merge branch 'master' into ov_file_path_util_file_size
mlukasze 69b84e1
Merge branch 'master' into ov_file_path_util_file_size
barnasm1 1fb30c1
Remove wstring_convert_util.cpp from source files properties in CMake…
barnasm1 3ed752e
fix: update file names in tests to remove underscores
barnasm1 7b44026
fix: update file_util tests on for unix
barnasm1 60e848c
test: add/fix tests for file size with Unicode character file names
barnasm1 073dde2
fix: add make_path overload for char* in file_util.hpp
barnasm1 190dd78
fix: add char* overload for file_size and simplify make_path usage in…
barnasm1 72978e5
refactor: remove Android-specific path handling code and associated t…
barnasm1 49422c4
Merge branch 'master' into ov_file_path_util_file_size
mlukasze 4357671
Remove conditional compilation for make_path function in file_util.hpp
barnasm1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.