namespace FileUtils

Overview

namespace FileUtils {

// typedefs

typedef typename std::enable_if<(std::is_same<C, char>::value||std::is_same<C, wchar_t>::value)>::type enableIfSupportedChar;

// global functions

std::string absoluteFilePath(const std::string& filePath);
void createDirectoryRecursive(const std::string& dirPath);
bool directoryExists(const std::string& path);
long long fileSize(const char \* fileName);

template <typename C, typename = enableIfSupportedChar<C>>
long long fileSize(const std::basic_string<C>& f);

template <typename C, typename = enableIfSupportedChar<C>>
bool fileExist(const C \* fileName);

template <typename C, typename = enableIfSupportedChar<C>>
bool fileExist(const std::basic_string<C>& fileName);

template <typename C, typename = enableIfSupportedChar<C>>
std::basic_string<C> makePath(
    const std::basic_string<C>& folder,
    const std::basic_string<C>& file
    );

template <typename C, typename = enableIfSupportedChar<C>>
std::basic_string<C> fileExt(const std::basic_string<C>& filename);

template <typename C, typename = enableIfSupportedChar<C>>
std::basic_string<C> makePluginLibraryName(
    const std::basic_string<C>& path,
    const std::basic_string<C>& input
    );

} // namespace FileUtils

Detailed Documentation

Typedefs

typedef typename std::enable_if<(std::is_same<C, char>::value||std::is_same<C, wchar_t>::value)>::type enableIfSupportedChar

Enables only char or wchar_t template specializations.

Parameters:

C

A char type

Global Functions

std::string absoluteFilePath(const std::string& filePath)

Interface function to get absolute path of file.

Parameters:

filePath

  • path to file, can be relative to current working directory

InferenceEngine::Exception

if any error occurred

Returns:

Absolute path of file

void createDirectoryRecursive(const std::string& dirPath)

Interface function to create directorty recursively by given path.

Parameters:

dirPath

  • path to file, can be relative to current working directory

InferenceEngine::Exception

if any error occurred

bool directoryExists(const std::string& path)

Interface function to check if directory exists for given path.

Parameters:

path

  • path to directory

Returns:

true if directory exists, false otherwise

long long fileSize(const char \* fileName)

Interface function to get the size of a file. The function supports UNICODE path.

Parameters:

fileName

  • name of the file

Returns:

size of the file

template <typename C, typename = enableIfSupportedChar<C>>
long long fileSize(const std::basic_string<C>& f)

Function to get the size of a file. The function supports UNICODE path.

Parameters:

f

  • string name of the file

Returns:

size of the file

template <typename C, typename = enableIfSupportedChar<C>>
bool fileExist(const C \* fileName)

check if file with a given filename exists. The function supports UNICODE path

Parameters:

fileName

  • given filename

Returns:

true is exists

template <typename C, typename = enableIfSupportedChar<C>>
bool fileExist(const std::basic_string<C>& fileName)

check if file with a given filename exists. The function supports UNICODE path

Parameters:

fileName

  • string with a given filename

Returns:

true is exists

template <typename C, typename = enableIfSupportedChar<C>>
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.

Parameters:

folder

  • path to add filename to

file

  • filename to add to path

Returns:

string with combination of the path and the filename divided by file separator

template <typename C, typename = enableIfSupportedChar<C>>
std::basic_string<C> fileExt(const std::basic_string<C>& filename)

CPP Interface function to extract extension from filename.

Parameters:

filename

  • string with the name of the file which extension should be extracted

Returns:

string with extracted file extension