21 #ifdef ENABLE_UNICODE_PATH_SUPPORT
28 INFERENCE_ENGINE_API_CPP(std::string) wStringtoMBCSstringChar(
const std::wstring& wstr);
35 INFERENCE_ENGINE_API_CPP(std::wstring) multiByteCharToWString(
const char* str);
47 constexpr
static const auto FileSeparator = ::FileUtils::FileSeparator;
48 static std::string PluginLibraryPrefix() {
return { }; }
49 static std::string PluginLibraryExt() {
return {
"dll" }; }
51 template<>
struct FileTraits<wchar_t> {
53 static std::wstring PluginLibraryPrefix() {
return { }; }
54 static std::wstring PluginLibraryExt() {
return { L
"dll" }; }
56 #elif defined __APPLE__
59 template<>
struct FileTraits<char> {
60 constexpr
static const auto FileSeparator = ::FileUtils::FileSeparator;
61 static std::string PluginLibraryPrefix() {
return {
"lib" }; }
62 static std::string PluginLibraryExt() {
return {
"so" }; }
64 template<>
struct FileTraits<wchar_t> {
66 static std::wstring PluginLibraryPrefix() {
return { L
"lib" }; }
67 static std::wstring PluginLibraryExt() {
return { L
"so" }; }
73 constexpr
static const auto FileSeparator = ::FileUtils::FileSeparator;
74 static std::string PluginLibraryPrefix() {
return {
"lib" }; }
75 static std::string PluginLibraryExt() {
return {
"so" }; }
79 static std::wstring PluginLibraryPrefix() {
return { L
"lib" }; }
80 static std::wstring PluginLibraryExt() {
return { L
"so" }; }
115 INFERENCE_ENGINE_API(
long long)
fileSize(
const char *fileName);
117 #ifdef ENABLE_UNICODE_PATH_SUPPORT
127 inline long long fileSize(
const wchar_t* fileName) {
128 return fileSize(::FileUtils::wStringtoMBCSstringChar(fileName).c_str());
139 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
140 inline long long fileSize(
const std::basic_string<C> &f) {
150 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
161 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
162 inline bool fileExist(
const std::basic_string<C> &fileName) {
174 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
175 inline std::basic_string<C>
makePath(
const std::basic_string<C> &folder,
const std::basic_string<C> &file) {
182 template <>
struct DotSymbol<char> { constexpr
static const char value =
'.'; };
183 template <>
struct DotSymbol<wchar_t> { constexpr
static const wchar_t value = L
'.'; };
191 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
192 inline std::basic_string<C>
fileExt(
const std::basic_string<C> &filename) {
194 if (pos == std::string::npos)
196 return filename.substr(pos + 1);
199 template <
typename C,
typename = InferenceEngine::details::enableIfSupportedChar<C>>
200 inline std::basic_string<C> makePluginLibraryName(
const std::basic_string<C> &path,
const std::basic_string<C> &input) {
201 std::basic_string<C> separator(1, FileTraits<C>::FileSeparator);
204 return path + separator + FileTraits<C>::PluginLibraryPrefix() + input + DotSymbol<C>::value + FileTraits<C>::PluginLibraryExt();
207 #ifdef ENABLE_UNICODE_PATH_SUPPORT
209 using FilePath = std::wstring;
211 inline std::string fromFilePath(
const FilePath & path) {
212 return ::FileUtils::wStringtoMBCSstringChar(path);
215 inline FilePath toFilePath(
const std::string & path) {
216 return ::FileUtils::multiByteCharToWString(path.c_str());
221 using FilePath = std::string;
223 inline std::string fromFilePath(
const FilePath & path) {
227 inline FilePath toFilePath(
const std::string & path) {
245 #ifdef ENABLE_UNICODE_PATH_SUPPORT
252 INFERENCE_ENGINE_API_CPP(std::wstring) getIELibraryPathW();
254 inline ::FileUtils::FilePath getInferenceEngineLibraryPath() {
255 return getIELibraryPathW();
260 inline ::FileUtils::FilePath getInferenceEngineLibraryPath() {
const char FileSeparator
File path separator.
Definition: file_utils.h:71
void createDirectoryRecursive(const std::string &dirPath)
Interface function to create directorty recursively by given path.
std::string getIELibraryPath()
Returns a path to Inference Engine library.
long long fileSize(const std::basic_string< C > &f)
Function to get the size of a file. The function supports UNICODE path.
Definition: file_utils.h:140
std::basic_string< C > fileExt(const std::basic_string< C > &filename)
CPP Interface function to extract extension from filename.
Definition: file_utils.h:192
std::string absoluteFilePath(const std::string &filePath)
Interface function to get absolute path of file.
std::basic_string< C > makePath(const std::basic_string< C > &folder, const std::basic_string< C > &file)
CPP Interface function to combint path with filename. The function supports UNICODE path.
Definition: file_utils.h:175
bool fileExist(const std::basic_string< C > &fileName)
check if file with a given filename exists. The function supports UNICODE path
Definition: file_utils.h:162
bool directoryExists(const std::string &path)
Interface function to check if directory exists for given path.
Inference Engine Plugin API namespace.
Definition: file_utils.h:181
Definition: file_utils.h:39