-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CORE] OV file utils file_size use std file path #28462
base: master
Are you sure you want to change the base?
[CORE] OV file utils file_size use std file path #28462
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions are not cast rename file or keep them in original header.
Why these function are moved to new file?
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17) | ||
inline ov::util::Path WPath(const std::wstring& wpath) { | ||
return {ov::util::wstring_to_string(wpath)}; | ||
} | ||
#else | ||
inline ov::util::Path WPath(const std::wstring& wpath) { | ||
return {wpath}; | ||
} | ||
#endif | ||
|
||
} // namespace util | ||
} // namespace ov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17) | |
inline ov::util::Path WPath(const std::wstring& wpath) { | |
return {ov::util::wstring_to_string(wpath)}; | |
} | |
#else | |
inline ov::util::Path WPath(const std::wstring& wpath) { | |
return {wpath}; | |
} | |
#endif | |
} // namespace util | |
} // namespace ov | |
} // namespace util | |
} // namespace ov | |
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17) | |
template<> | |
ov::util::Path::path<std::wstring>(const std::wstring& source, format fmt) : path(ov::util::wstring_to_string(source), std::move(fmt)) {} | |
#endif |
Consider add specialization for compiler version where is bug with path creation then WPath
function is not required and path can be create always in same way.
Optionally: If any issue because specialization already defined add some trait check to detect it and avoid define it in OV.
#endif | ||
|
||
#if defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3) | ||
# define GCC_VER_LESS_THEN_12_3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# define GCC_VER_LESS_THEN_12_3 | |
# define GCC_VER_LESS_THAN_12_3 |
Use than
in case where something is compared.
@@ -172,26 +161,30 @@ bool directory_exists(const std::string& path); | |||
bool directory_exists(const std::wstring& path); | |||
#endif | |||
|
|||
inline ov::util::Path cut_android_path(const ov::util::Path& file_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not required can be still internal part of file_size
if (pos != std::string::npos) { | ||
file_name = file_name.substr(0, pos); | ||
} | ||
inline int64_t file_size(const ov::util::Path& path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline int64_t file_size(const ov::util::Path& path) { | |
inline int64_t file_size(const ov::util::Path& path) { | |
#if defined(__ANDROID__) || defined(ANDROID) | |
// apply cuting if std::filesytem not support it well. | |
#endif | |
return std::filesystem::file_size(path); | |
} |
This function should probably be wrapper to std
implementation if works.
} | ||
{ | ||
std::ofstream outfile("test_file_21.txt"); | ||
outfile << "This is a test file." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outfile << "This is a test file." << std::endl; |
Remove there is no need to print messages if there is no failures.
{ | ||
std::ofstream outfile("test_file_21.txt"); | ||
outfile << "This is a test file." << std::endl; | ||
outfile.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required? It should be closed when outfile
will go out of scope of this block.
ov::util::Path file_name = std::get<0>(GetParam()); | ||
ov::util::Path expected = std::get<1>(GetParam()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ov::util::Path file_name = std::get<0>(GetParam()); | |
ov::util::Path expected = std::get<1>(GetParam()); | |
const auto& [file_name, expected] = GetParam(); |
In cpp17 it should work.
/** | ||
* @brief Returns file size for file | ||
* @param[in] path The file name | ||
* @return file size | ||
*/ | ||
inline int64_t file_size(const char* path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still this version should be kept and marked deprecated before remove.
@@ -0,0 +1,31 @@ | |||
// Copyright (C) 2018-2024 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright (C) 2018-2024 Intel Corporation | |
// Copyright (C) 2018-2025 Intel Corporation |
Check all modified files
#endif | ||
|
||
#if defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3) | ||
# define GCC_VER_LESS_THEN_12_3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# define GCC_VER_LESS_THEN_12_3 | |
# define GCC_VER_LESS_THAN_12_3 |
#endif | ||
|
||
#if defined(__clang__) && __clang_major__ < 17 | ||
# define CLANG_VER_LESS_THEN_17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# define CLANG_VER_LESS_THEN_17 | |
# define CLANG_VER_LESS_THAN_17 |
@@ -30,5 +37,15 @@ using Path = std::filesystem::path; | |||
using Path = std::experimental::filesystem::path; | |||
#endif | |||
|
|||
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17) | |
#if defined(GCC_VER_LESS_THAN_12_3) || defined(CLANG_VER_LESS_THAN_17) |
namespace ov { | ||
namespace util { | ||
|
||
#if defined(OPENVINO_HAS_FILESYSTEM) | ||
// There are known issues related with usage of std::filesystem::path unocode represenataion: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// There are known issues related with usage of std::filesystem::path unocode represenataion: | |
// There are known issues with usage of std::filesystem::path unicode representation: |
Details:
Tickets: