1#ifndef IOUTILITIES_PATHHELPER_H
2#define IOUTILITIES_PATHHELPER_H
13#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
17#ifdef PLATFORM_WINDOWS
18#define PATH_SEP_CHAR '\\'
19#define SEARCH_PATH_SEP_CHAR ';'
20#define PATH_SEP_STR "\\"
21#define SEARCH_PATH_SEP_STR ";"
23#define PATH_SEP_CHAR '/'
24#define SEARCH_PATH_SEP_CHAR ':'
25#define PATH_SEP_STR "/"
26#define SEARCH_PATH_SEP_STR ":"
33#ifdef CPP_UTILITIES_PATHHELPER_STRING_VIEW
42#ifdef PLATFORM_WINDOWS
48#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
49static_assert(std::is_same_v<typename std::filesystem::path::value_type, PathValueType>);
77#ifdef PLATFORM_WINDOWS
84#ifdef PLATFORM_WINDOWS
85 auto ec = std::error_code();
86 return convertMultiByteToWide(ec, path);
97#ifdef PLATFORM_WINDOWS
104#ifdef PLATFORM_WINDOWS
106 return std::string(res.first.get(), res.second);
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
Contains all utilities provides by the c++utilities library.
PathStringView extractNativePath(NativePathStringView path)
Returns path as UTF-8 string or string view.
CPP_UTILITIES_EXPORT StringData convertUtf16LEToUtf8(const char *inputBuffer, std::size_t inputBufferSize)
Converts the specified UTF-16 (little-endian) string to UTF-8.
std::basic_string< PathValueType > NativePathString
The string type used to store paths in the native encoding.
char PathValueType
The native type used by std::filesystem:path.
std::string_view PathStringView
The string view type used to pass paths UTF-8 encoded.
std::basic_string_view< PathValueType > NativePathStringView
The string view type used to pass paths in the native encoding.
std::string PathString
The string type used to store paths UTF-8 encoded.
CPP_UTILITIES_EXPORT void removeInvalidChars(std::string &fileName)
Removes invalid characters from the specified fileName.
CPP_UTILITIES_EXPORT std::string fileName(const std::string &path)
Returns the file name and extension of the specified path string.
NativePathStringView makeNativePath(PathStringView path)
Returns path in the platform's native encoding.
CPP_UTILITIES_EXPORT std::string directory(const std::string &path)
Returns the directory of the specified path string (including trailing slash).