1#ifndef IOUTILITIES_PATHHELPER_H
2#define IOUTILITIES_PATHHELPER_H
12#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
16#ifdef PLATFORM_WINDOWS
17#define PATH_SEP_CHAR '\\'
18#define SEARCH_PATH_SEP_CHAR ';'
19#define PATH_SEP_STR "\\"
20#define SEARCH_PATH_SEP_STR ";"
22#define PATH_SEP_CHAR '/'
23#define SEARCH_PATH_SEP_CHAR ':'
24#define PATH_SEP_STR "/"
25#define SEARCH_PATH_SEP_STR ":"
32#ifdef CPP_UTILITIES_PATHHELPER_STRING_VIEW
41#ifdef PLATFORM_WINDOWS
47#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
48static_assert(std::is_same_v<typename std::filesystem::path::value_type, PathValueType>);
76#ifdef PLATFORM_WINDOWS
83#ifdef PLATFORM_WINDOWS
84 auto ec = std::error_code();
85 return convertMultiByteToWide(ec, path);
91#if !defined(CPP_UTILITIES_NO_ICONV) || !defined(PLATFORM_WINDOWS)
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 provided 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).