libwinpr-path: extend custom portability functions

This commit is contained in:
Marc-André Moreau 2013-11-09 23:38:22 -05:00
parent 0e662a060e
commit 4898868e9d
3 changed files with 45 additions and 2 deletions

View File

@ -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

View File

@ -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
*/

View File

@ -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;