diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-04 14:57:45 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-04 16:12:11 +0000 |
commit | 9ac98e6e3488e434bf4864ecfb13a121784f640b (patch) | |
tree | b3c9cbf52126fee5864be12e9109f7413e7a0878 /sal/osl/w32/file_url.cxx | |
parent | 6f995da5a652d993ab253b3363188cd18e289728 (diff) |
Finally switch MSVC to sal_Unicode = char16_t, too
There is lots of (Windows-only) code that relied on sal_Unicode being the same
as wchar_t, and the best change may be different in each case (and doing the
changes may be somewhat error prone). So for now add SAL_U/SAL_W scaffolding
functions to sal/types.h, remove their uses one by one again, and finally drop
those functions again.
Change-Id: I2cc791bd941d089901abb5f6fc2f05fbc49e65ea
Reviewed-on: https://gerrit.libreoffice.org/36077
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/osl/w32/file_url.cxx')
-rw-r--r-- | sal/osl/w32/file_url.cxx | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index c1b84cbf5a02..2cfa469b3c66 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -156,7 +156,7 @@ static BOOL IsValidFilePathComponent( DWORD IsValidFilePath(rtl_uString *path, LPCWSTR *lppError, DWORD dwFlags, rtl_uString **corrected) { - LPCWSTR lpszPath = path->buffer; + LPCWSTR lpszPath = SAL_W(path->buffer); LPCWSTR lpComponent = lpszPath; BOOL fValid = TRUE; DWORD dwPathType = PATHTYPE_ERROR; @@ -170,13 +170,13 @@ DWORD IsValidFilePath(rtl_uString *path, LPCWSTR *lppError, DWORD dwFlags, rtl_u DWORD dwCandidatPathType = PATHTYPE_ERROR; - if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, WSTR_LONG_PATH_PREFIX_UNC, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) + if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, SAL_U(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) { /* This is long path in UNC notation */ lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1; dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH; } - else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, WSTR_LONG_PATH_PREFIX, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) + else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { /* This is long path */ lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1; @@ -281,7 +281,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCWSTR *lppError, DWORD dwFlags, rtl_u sal_Int32 i = lpComponent - lpszPath; rtl_uString_newReplaceStrAt(corrected, path, i, 1, nullptr); //TODO: handle out-of-memory - lpszPath = (*corrected)->buffer; + lpszPath = SAL_W((*corrected)->buffer); lpComponent = lpszPath + i; } @@ -672,7 +672,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p /* Indicates local root */ if ( nDecodedLen == nSkip ) - rtl_uString_newFromStr_WithLength( &strTempPath, WSTR_SYSTEM_ROOT_PATH, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ); + rtl_uString_newFromStr_WithLength( &strTempPath, SAL_U(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ); else { /* do not separate the directory and file case, so the maximal path length without prefix is MAX_PATH-12 */ @@ -683,14 +683,14 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p else { ::osl::LongPathBuffer< sal_Unicode > aBuf( MAX_LONG_PATH ); - sal_uInt32 nNewLen = GetCaseCorrectPathName( pDecodedURL + nSkip, + sal_uInt32 nNewLen = GetCaseCorrectPathName( SAL_W(pDecodedURL) + nSkip, ::osl::mingw_reinterpret_cast<LPWSTR>(aBuf), aBuf.getBufSizeInSymbols(), false ); if ( nNewLen <= MAX_PATH - 12 - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_SYSTEM_ROOT_PATH, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_LONG_PATH_PREFIX, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, SAL_U(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen ); } @@ -699,7 +699,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p /* it should be an UNC path, use the according prefix */ rtl_uString *strSuffix = nullptr; rtl_uString *strPrefix = nullptr; - rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX_UNC, SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, SAL_U(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf + 2, nNewLen - 2 ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -711,7 +711,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p { rtl_uString *strSuffix = nullptr; rtl_uString *strPrefix = nullptr; - rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX, SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf, nNewLen ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -903,8 +903,8 @@ oslFileError SAL_CALL osl_searchFileURL( do { /* If search path is empty use a nullptr pointer instead according to MSDN documentation of SearchPath */ - LPCWSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? ustrSystemSearchPath->buffer : nullptr; - LPCWSTR lpszSearchFile = ustrSysPath->buffer; + LPCWSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? SAL_W(ustrSystemSearchPath->buffer) : nullptr; + LPCWSTR lpszSearchFile = SAL_W(ustrSysPath->buffer); /* Allocate space for buffer according to previous returned count of required chars */ /* +1 is not necessary if we follow MSDN documentation but for robustness we do so */ @@ -921,7 +921,7 @@ oslFileError SAL_CALL osl_searchFileURL( if ( dwResult ) { - rtl_uString_newFromStr( &ustrSysPath, lpBuffer ); + rtl_uString_newFromStr( &ustrSysPath, SAL_U(lpBuffer) ); error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); } else @@ -932,7 +932,7 @@ oslFileError SAL_CALL osl_searchFileURL( /* something went wrong, perhaps the path was absolute */ error = oslTranslateFileError( GetLastError() ); - hFind = FindFirstFile( ustrSysPath->buffer, &aFindFileData ); + hFind = FindFirstFile( SAL_W(ustrSysPath->buffer), &aFindFileData ); if ( IsValidHandle(hFind) ) { @@ -991,10 +991,10 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr osl_acquireMutex( g_CurrentDirectoryMutex ); GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aCurrentDir) ); - SetCurrentDirectoryW( ustrBaseSysPath->buffer ); + SetCurrentDirectoryW( SAL_W(ustrBaseSysPath->buffer) ); } - dwResult = GetFullPathNameW( ustrRelSysPath->buffer, aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), &lpFilePart ); + dwResult = GetFullPathNameW( SAL_W(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), &lpFilePart ); if ( ustrBaseSysPath ) { |