diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h index 9c3ec4c01..811cfdb07 100644 --- a/winpr/include/winpr/path.h +++ b/winpr/include/winpr/path.h @@ -242,14 +242,19 @@ WINPR_API HRESULT NativePathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsi WINPR_API HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags); WINPR_API HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlags); +WINPR_API char PathGetSeparatorA(unsigned long dwFlags); +WINPR_API WCHAR PathGetSeparatorW(unsigned long dwFlags); + WINPR_API PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags); WINPR_API PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags); #ifdef UNICODE #define PathCchConvertStyle PathCchConvertStyleW +#define PathGetSeparator PathGetSeparatorW #define PathGetSharedLibraryExtension PathGetSharedLibraryExtensionW #else #define PathCchConvertStyle PathCchConvertStyleA +#define PathGetSeparator PathGetSeparatorW #define PathGetSharedLibraryExtension PathGetSharedLibraryExtensionA #endif @@ -276,7 +281,7 @@ extern "C" { WINPR_API char* GetKnownPath(int id); WINPR_API char* GetKnownSubPath(int id, char* path); -WINPR_API char* GetCombinedPath(char* basePath, char* subPath); +WINPR_API char* GetCombinedPath(const char* basePath, const char* subPath); //#ifndef _WIN32 diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index 22f8a1365..45e9fb129 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -829,6 +829,44 @@ HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlag return S_OK; } +/** + * PathGetSeparator + */ + +char PathGetSeparatorA(unsigned long dwFlags) +{ + char separator = PATH_SEPARATOR_CHR; + + if (!dwFlags) + dwFlags = PATH_STYLE_NATIVE; + + if (dwFlags == PATH_STYLE_WINDOWS) + separator = PATH_SEPARATOR_CHR; + else if (dwFlags == PATH_STYLE_UNIX) + separator = PATH_SEPARATOR_CHR; + else if (dwFlags == PATH_STYLE_NATIVE) + separator = PATH_SEPARATOR_CHR; + + return separator; +} + +WCHAR PathGetSeparatorW(unsigned long dwFlags) +{ + WCHAR separator = PATH_SEPARATOR_CHR; + + if (!dwFlags) + dwFlags = PATH_STYLE_NATIVE; + + if (dwFlags == PATH_STYLE_WINDOWS) + separator = PATH_SEPARATOR_CHR; + else if (dwFlags == PATH_STYLE_UNIX) + separator = PATH_SEPARATOR_CHR; + else if (dwFlags == PATH_STYLE_NATIVE) + separator = PATH_SEPARATOR_CHR; + + return separator; +} + /** * PathGetSharedLibraryExtension */ diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index 573ee0320..c7ead6871 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -271,7 +271,7 @@ char* GetKnownSubPath(int id, char* path) return subPath; } -char* GetCombinedPath(char* basePath, char* subPath) +char* GetCombinedPath(const char* basePath, const char* subPath) { int length; HRESULT status;