summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-03-31 13:21:38 +0200
committerVladimir Glazunov <vg@openoffice.org>2010-03-31 13:21:38 +0200
commit9734c73c9a61fc5ef4e263617add17914a9b5f15 (patch)
tree95ca1d6883126a3a59956d942e03062c3d38af65
parent1a1c3d945c76eeb6617294b95b5a987339be217c (diff)
parent94924dfeda6f8505b829c5244553fefc958a0211 (diff)
CWS-TOOLING: integrate CWS mingwport29
Notes
split repo tag: ure_ooo/DEV300_m76
-rw-r--r--sal/osl/w32/file_dirvol.cxx8
-rw-r--r--sal/osl/w32/file_url.cxx28
-rw-r--r--sal/osl/w32/module.cxx8
-rw-r--r--sal/osl/w32/path_helper.hxx3
-rw-r--r--sal/osl/w32/process.cxx12
-rw-r--r--sal/osl/w32/profile.cxx105
-rw-r--r--sal/osl/w32/tempfile.cxx2
7 files changed, 86 insertions, 80 deletions
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 734824d63e57..09bdec7988c3 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -529,7 +529,7 @@ static oslFileError osl_openLocalRoot(
rtl_uString* pBackSlash = 0;
rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
- rtl_uString_newFromStr( &pBackSlash, L"\\" );
+ rtl_uString_newFromAscii( &pBackSlash, "\\" );
rtl_uString_newConcat( &pDirImpl->m_pDirectoryPath, pCurDir, pBackSlash );
rtl_uString_release( pBackSlash );
rtl_uString_release( pCurDir );
@@ -594,7 +594,7 @@ static oslFileError SAL_CALL osl_openFileDirectory(
rtl_uString* pBackSlash = 0;
rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
- rtl_uString_newFromStr( &pBackSlash, L"\\" );
+ rtl_uString_newFromAscii( &pBackSlash, "\\" );
rtl_uString_newConcat( &pDirImpl->m_pDirectoryPath, pCurDir, pBackSlash );
rtl_uString_release( pBackSlash );
rtl_uString_release( pCurDir );
@@ -964,7 +964,7 @@ static oslFileError SAL_CALL osl_getNextFileItem(
pItemImpl->nRefCount = 1;
rtl_uString* pTmpFileName = 0;
- rtl_uString_newFromStr( &pTmpFileName, pItemImpl->FindData.cFileName );
+ rtl_uString_newFromStr( &pTmpFileName, reinterpret_cast<const sal_Unicode *>(pItemImpl->FindData.cFileName) );
rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName );
rtl_uString_release( pTmpFileName );
@@ -1754,7 +1754,7 @@ oslFileError SAL_CALL osl_getFileStatus(
sal_uInt32 nLen = rtl_uString_getLength( pItemImpl->m_pFullPath );
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
sal_uInt32 nNewLen = GetCaseCorrectPathName( reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pItemImpl->m_pFullPath ) ),
- aBuffer,
+ ::osl::mingw_reinterpret_cast<LPTSTR>( aBuffer ),
aBuffer.getBufSizeInSymbols(),
sal_True );
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 8e11be1d6a5c..90140cda97c6 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -252,13 +252,13 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
DWORD dwCandidatPathType = PATHTYPE_ERROR;
- if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, WSTR_LONG_PATH_PREFIX_UNC, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) )
+ if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX_UNC), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) )
{
/* This is long path in UNC notation */
lpComponent = lpszPath + ELEMENTS_OF_ARRAY(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, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
+ else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, reinterpret_cast<const sal_Unicode *>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
{
/* This is long path */
lpComponent = lpszPath + ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1;
@@ -465,7 +465,7 @@ static DWORD GetCaseCorrectPathNameEx(
DWORD nSkipLevels,
BOOL bCheckExistence )
{
- ::osl::LongPathBuffer< sal_Unicode > szFile( MAX_PATH + 1 );
+ ::osl::LongPathBuffer< WCHAR > szFile( MAX_PATH + 1 );
sal_Int32 nRemoved = PathRemoveFileSpec( lpszPath, szFile, MAX_PATH + 1 );
sal_Int32 nLastStepRemoved = nRemoved;
while ( nLastStepRemoved && szFile[0] == 0 )
@@ -505,7 +505,7 @@ static DWORD GetCaseCorrectPathNameEx(
{
if ( bCheckExistence )
{
- ::osl::LongPathBuffer< sal_Unicode > aShortPath( MAX_LONG_PATH );
+ ::osl::LongPathBuffer< WCHAR > aShortPath( MAX_LONG_PATH );
_tcscpy( aShortPath, lpszPath );
_tcscat( aShortPath, szFile );
@@ -777,14 +777,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,
- aBuf,
+ sal_uInt32 nNewLen = GetCaseCorrectPathName( reinterpret_cast<LPCTSTR>(pDecodedURL + nSkip),
+ ::osl::mingw_reinterpret_cast<LPTSTR>(aBuf),
aBuf.getBufSizeInSymbols(),
sal_False );
if ( nNewLen <= MAX_PATH - 12
- || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_SYSTEM_ROOT_PATH, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 )
- || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_LONG_PATH_PREFIX, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
+ || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 )
+ || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
{
rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen );
}
@@ -793,7 +793,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
/* it should be an UNC path, use the according prefix */
rtl_uString *strSuffix = NULL;
rtl_uString *strPrefix = NULL;
- rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX_UNC, ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1 );
+ rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX_UNC), ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1 );
rtl_uString_newFromStr_WithLength( &strSuffix, aBuf + 2, nNewLen - 2 );
rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
@@ -805,7 +805,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
{
rtl_uString *strSuffix = NULL;
rtl_uString *strPrefix = NULL;
- rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX, ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1 );
+ rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1 );
rtl_uString_newFromStr_WithLength( &strSuffix, aBuf, nNewLen );
rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
@@ -1093,15 +1093,15 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
{
osl_acquireMutex( g_CurrentDirectoryMutex );
- GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), aCurrentDir );
- SetCurrentDirectoryW( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) );
+ GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aCurrentDir) );
+ SetCurrentDirectoryW( reinterpret_cast<LPCWSTR>(ustrBaseSysPath->buffer) );
}
- dwResult = GetFullPathNameW( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), aBuffer, &lpFilePart );
+ dwResult = GetFullPathNameW( reinterpret_cast<LPCWSTR>(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), &lpFilePart );
if ( ustrBaseSysPath )
{
- SetCurrentDirectoryW( aCurrentDir );
+ SetCurrentDirectoryW( ::osl::mingw_reinterpret_cast<LPCWSTR>(aCurrentDir) );
osl_releaseMutex( g_CurrentDirectoryMutex );
}
diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 98ffd0bc09d4..b730bd3347df 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -64,9 +64,9 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod
if ( osl_File_E_None != nError )
rtl_uString_assign(&Module, strModuleName);
- hInstance = LoadLibraryW(Module->buffer);
+ hInstance = LoadLibraryW(reinterpret_cast<LPCWSTR>(Module->buffer));
if (hInstance == NULL)
- hInstance = LoadLibraryExW(Module->buffer, NULL,
+ hInstance = LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
if (hInstance <= (HINSTANCE)HINSTANCE_ERROR)
@@ -88,7 +88,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMod
sal_Bool SAL_CALL
osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult)
{
- HINSTANCE hInstance = GetModuleHandleW(pModuleName->buffer);
+ HINSTANCE hInstance = GetModuleHandleW(reinterpret_cast<LPCWSTR>(pModuleName->buffer));
if( hInstance )
{
*pResult = (oslModule) hInstance;
@@ -429,7 +429,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
rtl_uString *ustrSysPath = NULL;
- GetModuleFileNameW( lpModules[iModule], aBuffer, aBuffer.getBufSizeInSymbols() );
+ GetModuleFileNameW( lpModules[iModule], ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), aBuffer.getBufSizeInSymbols() );
rtl_uString_newFromStr( &ustrSysPath, aBuffer );
osl_getFileURLFromSystemPath( ustrSysPath, pustrURL );
diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx
index 64b0ac573da3..d157b42aa428 100644
--- a/sal/osl/w32/path_helper.hxx
+++ b/sal/osl/w32/path_helper.hxx
@@ -108,8 +108,11 @@ public:
{
return m_pBuffer;
}
+
};
+ template< class U, class T > U mingw_reinterpret_cast(LongPathBuffer<T>& a) { return reinterpret_cast<U>(static_cast<T*>(a)); }
+
} // end namespace osl
#endif
diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index 12eda6658033..b8b2d3893345 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -227,7 +227,7 @@ extern "C" oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl (
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
DWORD buflen = 0;
- if ((buflen = GetModuleFileNameW (0, aBuffer, aBuffer.getBufSizeInSymbols())) > 0)
+ if ((buflen = GetModuleFileNameW (0, ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), aBuffer.getBufSizeInSymbols())) > 0)
{
rtl_uString * pAbsPath = 0;
rtl_uString_newFromStr_WithLength (&(pAbsPath), aBuffer, buflen);
@@ -279,7 +279,7 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char ** argv)
for (i = 0; i < nArgs; i++)
{
/* Convert to unicode */
- rtl_uString_newFromStr( &(ppArgs[i]), wargv[i] );
+ rtl_uString_newFromStr( &(ppArgs[i]), reinterpret_cast<const sal_Unicode*>(wargv[i]) );
}
if (ppArgs[0] != 0)
{
@@ -288,7 +288,7 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char ** argv)
DWORD dwResult = 0;
dwResult = SearchPath (
- 0, ppArgs[0]->buffer, L".exe", aBuffer.getBufSizeInSymbols(), aBuffer, 0);
+ 0, reinterpret_cast<LPCWSTR>(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), 0);
if ((0 < dwResult) && (dwResult < aBuffer.getBufSizeInSymbols()))
{
/* Replace argv[0] with it's absolute path */
@@ -401,9 +401,9 @@ oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *ustrVar, rtl_uString **
{
WCHAR buff[ENV_BUFFER_SIZE];
- if (GetEnvironmentVariableW(ustrVar->buffer, buff, ENV_BUFFER_SIZE) > 0)
+ if (GetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(ustrVar->buffer), buff, ENV_BUFFER_SIZE) > 0)
{
- rtl_uString_newFromStr(ustrValue, buff);
+ rtl_uString_newFromStr(ustrValue, reinterpret_cast<const sal_Unicode*>(buff));
return osl_Process_E_None;
}
return osl_Process_E_Unknown;
@@ -422,7 +422,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir
osl_acquireMutex( g_CurrentDirectoryMutex );
- dwLen = GetCurrentDirectory( aBuffer.getBufSizeInSymbols(), aBuffer );
+ dwLen = GetCurrentDirectory( aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer) );
osl_releaseMutex( g_CurrentDirectoryMutex );
if ( dwLen && dwLen < aBuffer.getBufSizeInSymbols() )
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index f30ac7ce3348..9f4ea5630e1f 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -36,6 +36,9 @@
#include <osl/file.h>
#include <osl/util.h>
#include <rtl/alloc.h>
+#include <algorithm>
+using std::min;
+static inline void copy_ustr_n( void *dest, const void *source, size_t length ) { rtl_copyMemory(dest, source, length*sizeof(sal_Unicode)); }
#define LINES_INI 32
#define LINES_ADD 10
@@ -503,7 +506,7 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
{
::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
GetPrivateProfileString(pszSection, pszEntry, pszDefault, pszString, MaxLen, aFileName);
}
@@ -684,7 +687,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
{
::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
WritePrivateProfileString(pszSection, pszEntry, pszString, aFileName);
}
@@ -795,7 +798,7 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
{
::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
WritePrivateProfileString(pszSection, pszEntry, NULL, aFileName);
}
@@ -869,7 +872,7 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C
{
::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
n = GetPrivateProfileString(pszSection, NULL, NULL, pszBuffer, MaxLen, aFileName);
}
@@ -900,7 +903,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if( ::sal::static_int_cast< sal_uInt32 >( strName->length ) >= aFile.getBufSizeInSymbols() )
return sal_False;
- wcscpy( aFile, strName->buffer);
+ copy_ustr_n( aFile, strName->buffer, strName->length+1);
nFileLen = strName->length;
if (rtl_ustr_indexOfChar( aFile, L'.' ) == -1)
@@ -909,7 +912,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
return sal_False;
/* add default extension */
- wcscpy( aFile + nFileLen, STR_INI_EXTENSION);
+ copy_ustr_n( aFile + nFileLen, STR_INI_EXTENSION, wcslen(STR_INI_EXTENSION)+1 );
nFileLen += wcslen(STR_INI_EXTENSION);
}
}
@@ -939,13 +942,13 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if ((nFileLen = nLen - nOffset) >= aFile.getBufSizeInSymbols())
return sal_False;
- wcsncpy(aFile, pProgName + nOffset, nFileLen);
+ copy_ustr_n(aFile, pProgName + nOffset, nFileLen);
if (nFileLen + wcslen(STR_INI_EXTENSION) >= aFile.getBufSizeInSymbols())
return sal_False;
/* add default extension */
- wcscpy(aFile + nFileLen, STR_INI_EXTENSION);
+ copy_ustr_n(aFile + nFileLen, STR_INI_EXTENSION, wcslen(STR_INI_EXTENSION)+1);
nFileLen += wcslen(STR_INI_EXTENSION);
rtl_uString_release( strProgName );
@@ -974,7 +977,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if ( ::sal::static_int_cast< sal_uInt32 >( strHome->length ) >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy( aPath, strHome->buffer);
+ copy_ustr_n( aPath, strHome->buffer, strHome->length+1);
nPathLen = strHome->length;
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METAHOME))
@@ -985,7 +988,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(aPath + nPathLen, pPath);
+ copy_ustr_n(aPath + nPathLen, pPath, nLen+1);
nPathLen += nLen;
}
@@ -1006,7 +1009,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if ( ::sal::static_int_cast< sal_uInt32 >( strConfig->length ) >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy( aPath, strConfig->buffer);
+ copy_ustr_n( aPath, strConfig->buffer, strConfig->length+1 );
nPathLen = strConfig->length;
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METACFG))
@@ -1017,7 +1020,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(aPath + nPathLen, pPath);
+ copy_ustr_n(aPath + nPathLen, pPath, nLen+1);
nPathLen += nLen;
}
@@ -1027,7 +1030,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METASYS), STR_INI_METASYS) == 0) &&
((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METASYS)] == '/')))
{
- if (((nPathLen = GetWindowsDirectoryW(aPath, aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols()))
+ if (((nPathLen = GetWindowsDirectoryW(::osl::mingw_reinterpret_cast<LPWSTR>(aPath), aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols()))
return (sal_False);
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METASYS))
@@ -1038,7 +1041,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(aPath + nPathLen, pPath);
+ copy_ustr_n(aPath + nPathLen, pPath, nLen+1);
nPathLen += nLen;
}
}
@@ -1050,13 +1053,13 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (! lookupProfile(pPath + RTL_CONSTASCII_LENGTH(STR_INI_METAINS), aFile, aPath))
return (sal_False);
- nPathLen = wcslen(aPath);
+ nPathLen = rtl_ustr_getLength(aPath);
}
else if( ::sal::static_int_cast< sal_uInt32 >( nLen ) < aPath.getBufSizeInSymbols())
{
- wcscpy(aPath, pPath);
- nPathLen = wcslen(aPath);
+ copy_ustr_n(aPath, pPath, nLen+1);
+ nPathLen = rtl_ustr_getLength(aPath);
}
else
return sal_False;
@@ -1073,7 +1076,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if ( ::sal::static_int_cast< sal_uInt32 >( strConfigDir->length ) >= aPath.getBufSizeInSymbols() )
return sal_False;
- wcscpy(aPath, strConfigDir->buffer);
+ copy_ustr_n(aPath, strConfigDir->buffer, strConfigDir->length+1);
nPathLen = strConfigDir->length;
}
@@ -1087,7 +1090,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
return sal_False;
/* append file name */
- wcscpy(aPath + nPathLen, aFile);
+ copy_ustr_n(aPath + nPathLen, aFile, nFileLen+1);
nPathLen += nFileLen;
/* copy filename */
@@ -1141,7 +1144,7 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff
{
::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(pProfile->m_strFileName->buffer), -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
n = GetPrivateProfileSectionNames(pszBuffer, MaxLen, aFileName);
}
@@ -1276,7 +1279,7 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi
OSL_TRACE("opening '%s' read only\n",pszFilename);
#endif
- pFile->m_Handle = CreateFileW( rtl_uString_getStr( strFileName ), GENERIC_READ,
+ pFile->m_Handle = CreateFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strFileName )), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -1289,7 +1292,7 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi
OSL_TRACE("opening '%s' read/write\n",pszFilename);
#endif
- if ((pFile->m_Handle = CreateFileW( rtl_uString_getStr( strFileName ), GENERIC_READ | GENERIC_WRITE,
+ if ((pFile->m_Handle = CreateFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strFileName )), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL))
== INVALID_HANDLE_VALUE)
@@ -2133,13 +2136,13 @@ static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile)
/* unlink bak */
- DeleteFileW( rtl_uString_getStr( ustrBakFile ) );
+ DeleteFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( ustrBakFile )) );
/* rename ini bak */
- MoveFileExW( rtl_uString_getStr( ustrIniFile ), rtl_uString_getStr( ustrBakFile ), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH );
+ MoveFileExW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( ustrIniFile )), reinterpret_cast<LPCWSTR>(rtl_uString_getStr( ustrBakFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH );
/* rename tmp ini */
- MoveFileExW( rtl_uString_getStr( ustrTmpFile ), rtl_uString_getStr( ustrIniFile ), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH );
+ MoveFileExW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( ustrTmpFile )), reinterpret_cast<LPCWSTR>(rtl_uString_getStr( ustrIniFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH );
return bRet;
}
@@ -2316,7 +2319,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
while ((strPath[i] != L'"') && (strPath[i] != L'\0'))
i++;
- WideCharToMultiByte(CP_ACP,0, strPath, i, Product, sizeof(Product), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(strPath), i, Product, sizeof(Product), NULL, NULL);
Product[i] = '\0';
strPath += i;
@@ -2443,31 +2446,31 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
((nEnd = rtl_ustr_indexOfChar(pCommandArg + nStart + 1, L']')) != -1))
{
dwPathLen = nEnd;
- wcsncpy(aPath, pCommandArg + nStart + 1, dwPathLen );
+ copy_ustr_n(aPath, pCommandArg + nStart + 1, dwPathLen);
aPath[dwPathLen] = 0;
/* build full path */
if ((aPath[dwPathLen - 1] != L'/') && (aPath[dwPathLen - 1] != L'\\'))
{
- wcscpy(aPath + dwPathLen++, L"/");
+ copy_ustr_n(aPath + dwPathLen++, L"/", 2);
}
if (*strPath)
{
- wcscpy(aPath + dwPathLen, strPath);
- dwPathLen += wcslen(strPath);
+ copy_ustr_n(aPath + dwPathLen, strPath, rtl_ustr_getLength(strPath)+1);
+ dwPathLen += rtl_ustr_getLength(strPath);
}
else
{
::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
int n;
- if ((n = WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL)) > 0)
+ if ((n = WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast<LPCWSTR>(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL)) > 0)
{
strcpy(aTmpPath + n, SVERSION_USER);
if (access(aTmpPath, 0) >= 0)
{
- dwPathLen += MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, aPath + dwPathLen, aPath.getBufSizeInSymbols() - dwPathLen );
+ dwPathLen += MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, reinterpret_cast<LPWSTR>(aPath + dwPathLen), aPath.getBufSizeInSymbols() - dwPathLen );
}
}
}
@@ -2507,14 +2510,14 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
else
{
- wcsncpy(aPath, strExecutable->buffer, nPos );
+ copy_ustr_n(aPath, strExecutable->buffer, nPos);
aPath[nPos] = 0;
dwPathLen = nPos;
}
}
else
{
- wcsncpy(aPath, strExecutable->buffer, nPos );
+ copy_ustr_n(aPath, strExecutable->buffer, nPos);
dwPathLen = nPos;
aPath[dwPathLen] = 0;
}
@@ -2522,7 +2525,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
/* if we have no product identification use the executable file name */
if (*Product == 0)
{
- WideCharToMultiByte(CP_ACP,0, strExecutable->buffer + nPos + 1, -1, Product, sizeof(Product), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, reinterpret_cast<LPCWSTR>(strExecutable->buffer + nPos + 1), -1, Product, sizeof(Product), NULL, NULL);
/* remove extension */
if ((pChr = strrchr(Product, '.')) != NULL)
@@ -2534,18 +2537,18 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
/* remember last subdir */
nPos = rtl_ustr_lastIndexOfChar(aPath, L'\\');
- wcscpy(aPath + dwPathLen++, L"\\");
+ copy_ustr_n(aPath + dwPathLen++, L"\\", 2);
if (*strPath)
{
- wcscpy(aPath + dwPathLen, strPath);
- dwPathLen += wcslen(strPath);
+ copy_ustr_n(aPath + dwPathLen, strPath, rtl_ustr_getLength(strPath)+1);
+ dwPathLen += rtl_ustr_getLength(strPath);
}
{
::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast<LPCWSTR>(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
/* if file not exists, remove any specified subdirectories
like "bin" or "program" */
@@ -2569,13 +2572,13 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
else
{
- dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, aPath + nPos + 1, aPath.getBufSizeInSymbols() - (nPos + 1) );
+ dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, reinterpret_cast<LPWSTR>(aPath + nPos + 1), aPath.getBufSizeInSymbols() - (nPos + 1) );
}
}
else
{
- wcscpy(aPath + nPos + 1, strPath);
- dwPathLen = nPos + 1 + wcslen(strPath);
+ copy_ustr_n(aPath + nPos + 1, strPath, rtl_ustr_getLength(strPath)+1);
+ dwPathLen = nPos + 1 + rtl_ustr_getLength(strPath);
}
break;
@@ -2589,12 +2592,12 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
aPath[dwPathLen] = 0;
}
- wcscpy(aPath + dwPathLen, strFile);
+ copy_ustr_n(aPath + dwPathLen, strFile, rtl_ustr_getLength(strFile)+1);
{
::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, ::osl::mingw_reinterpret_cast<LPCWSTR>(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
if ((access(aTmpPath, 0) < 0) && (strlen(Product) > 0))
{
@@ -2645,20 +2648,20 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
if (strlen(Buffer) > 0)
{
dwPathLen = MultiByteToWideChar(
- CP_ACP, 0, Buffer, -1, aPath, aPath.getBufSizeInSymbols() );
+ CP_ACP, 0, Buffer, -1, ::osl::mingw_reinterpret_cast<LPWSTR>(aPath), aPath.getBufSizeInSymbols() );
dwPathLen -=1;
/* build full path */
if ((aPath[dwPathLen - 1] != L'/')
&& (aPath[dwPathLen - 1] != L'\\'))
{
- wcscpy(aPath + dwPathLen++, L"\\");
+ copy_ustr_n(aPath + dwPathLen++, L"\\", 2);
}
if (*strPath)
{
- wcscpy(aPath + dwPathLen, strPath);
- dwPathLen += wcslen(strPath);
+ copy_ustr_n(aPath + dwPathLen, strPath, rtl_ustr_getLength(strPath)+1);
+ dwPathLen += rtl_ustr_getLength(strPath);
}
else
{
@@ -2666,7 +2669,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
int n;
if ((n = WideCharToMultiByte(
- CP_ACP,0, aPath, -1, aTmpPath,
+ CP_ACP,0, ::osl::mingw_reinterpret_cast<LPCWSTR>(aPath), -1, aTmpPath,
aTmpPath.getBufSizeInSymbols(), NULL, NULL))
> 0)
{
@@ -2675,7 +2678,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
{
dwPathLen += MultiByteToWideChar(
CP_ACP, 0, SVERSION_USER, -1,
- aPath + dwPathLen,
+ reinterpret_cast<LPWSTR>(aPath + dwPathLen),
aPath.getBufSizeInSymbols() - dwPathLen );
}
}
@@ -2696,7 +2699,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
/* copy filename */
- wcscpy(strProfile, aPath);
+ copy_ustr_n(strProfile, aPath, dwPathLen+1);
return sal_True;
}
diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx
index 4bf136b6b0e0..6a3d2549004a 100644
--- a/sal/osl/w32/tempfile.cxx
+++ b/sal/osl/w32/tempfile.cxx
@@ -240,7 +240,7 @@ oslFileError SAL_CALL osl_createTempFile(
oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
{
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
- LPWSTR lpBuffer = aBuffer;
+ LPWSTR lpBuffer = ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer);
DWORD nBufferLength = aBuffer.getBufSizeInSymbols() - 1;
DWORD nLength;