summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2015-11-10 20:47:58 -0500
committerCaolán McNamara <caolanm@redhat.com>2015-11-12 10:55:41 +0000
commit1a494d9a00208eef790400bdbd8b3e5c7fed4886 (patch)
tree9e305bbf11be0aacfa3af942a7c250f423b629a9 /sal
parentd7801c39826f2f24f7340e1b25809d3bb65d6099 (diff)
Windows header sanitization
Isolation of windows headers using prewin.h and postwin.h headers and making headers dependent on them more self contained. Conversion of TCHAR to WCHAR and LPCTSTR to LPCWSTR etc. and cleanup of unnecessary casts. Change-Id: I7eff5c477d9223a064bfb4d962ff6d61960ee69c Reviewed-on: https://gerrit.libreoffice.org/19901 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/w32/file.cxx14
-rw-r--r--sal/osl/w32/file_dirvol.cxx164
-rw-r--r--sal/osl/w32/file_url.cxx146
-rw-r--r--sal/osl/w32/file_url.h6
-rw-r--r--sal/osl/w32/procimpl.cxx48
5 files changed, 189 insertions, 189 deletions
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index 181e041c29bd..cb12df6fa488 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -718,7 +718,7 @@ SAL_CALL osl_openFile(
dwCreation |= OPEN_EXISTING;
HANDLE hFile = CreateFileW(
- reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )),
+ rtl_uString_getStr( strSysPath ),
dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL );
// @@@ ERROR HANDLING @@@
@@ -1089,7 +1089,7 @@ oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
if ( osl_File_E_None == error )
{
- if ( DeleteFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
+ if ( DeleteFile( rtl_uString_getStr( strSysPath ) ) )
error = osl_File_E_None;
else
error = oslTranslateFileError( GetLastError() );
@@ -1109,10 +1109,10 @@ oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPa
if ( osl_File_E_None == error )
{
- LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath ));
- LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath ));
+ LPCWSTR src = rtl_uString_getStr( strSysPath );
+ LPCWSTR dst = rtl_uString_getStr( strSysDestPath );
- if ( CopyFile( src, dst, FALSE ) )
+ if ( CopyFileW( src, dst, FALSE ) )
error = osl_File_E_None;
else
error = oslTranslateFileError( GetLastError() );
@@ -1136,8 +1136,8 @@ oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPa
if ( osl_File_E_None == error )
{
- LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath ));
- LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath ));
+ LPCWSTR src = rtl_uString_getStr( strSysPath );
+ LPCWSTR dst = rtl_uString_getStr( strSysDestPath );
if ( MoveFileEx( src, dst, MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING ) )
error = osl_File_E_None;
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 5f8aef4c32fb..e0ca7990c0c1 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -59,7 +59,7 @@ extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime
BaseSysTime.wSecond = 0;
BaseSysTime.wMilliseconds = 0;
- if (cpTimeVal==NULL)
+ if (cpTimeVal==nullptr)
return fSuccess;
if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) )
@@ -129,7 +129,7 @@ namespace /* private */
};
inline bool is_UNC_path(const sal_Unicode* path)
- { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), SAL_N_ELEMENTS(UNC_PREFIX) - 1)); }
+ { return (0 == wcsncmp(UNC_PREFIX, path, SAL_N_ELEMENTS(UNC_PREFIX) - 1)); }
inline bool is_UNC_path(const rtl::OUString& path)
{ return is_UNC_path(path.getStr()); }
@@ -244,7 +244,7 @@ struct DirectoryItem_Impl
UINT uType;
union {
WIN32_FIND_DATA FindData;
- TCHAR cDriveString[MAX_PATH];
+ WCHAR cDriveString[MAX_PATH];
};
rtl_uString* m_pFullPath;
BOOL bFullPathNormalized;
@@ -267,9 +267,9 @@ struct Directory_Impl
typedef struct tagDRIVEENUM
{
- LPCTSTR lpIdent;
- TCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256];
- LPCTSTR lpCurrent;
+ LPCWSTR lpIdent;
+ WCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256];
+ LPCWSTR lpCurrent;
} DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM;
static HANDLE WINAPI OpenLogicalDrivesEnum()
@@ -277,9 +277,9 @@ static HANDLE WINAPI OpenLogicalDrivesEnum()
LPDRIVEENUM pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) );
if ( pEnum )
{
- DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(TCHAR), pEnum->cBuffer );
+ DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(WCHAR), pEnum->cBuffer );
- if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(TCHAR) )
+ if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(WCHAR) )
{
pEnum->lpCurrent = pEnum->cBuffer;
pEnum->lpIdent = L"tagDRIVEENUM";
@@ -287,13 +287,13 @@ static HANDLE WINAPI OpenLogicalDrivesEnum()
else
{
HeapFree( GetProcessHeap(), 0, pEnum );
- pEnum = NULL;
+ pEnum = nullptr;
}
}
return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE;
}
-static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer)
+static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer)
{
BOOL fSuccess = FALSE;
LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
@@ -304,7 +304,7 @@ static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer)
if ( nLen )
{
- CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(TCHAR) );
+ CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(WCHAR) );
pEnum->lpCurrent += nLen + 1;
fSuccess = TRUE;
}
@@ -341,14 +341,14 @@ typedef struct tagDIRECTORY
static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
{
- LPDIRECTORY pDirectory = NULL;
+ LPDIRECTORY pDirectory = nullptr;
if ( pPath )
{
sal_uInt32 nLen = rtl_uString_getLength( pPath );
if ( nLen )
{
- const TCHAR* pSuffix = 0;
+ const WCHAR* pSuffix = 0;
sal_uInt32 nSuffLen = 0;
if ( pPath->buffer[nLen - 1] != L'\\' )
@@ -362,9 +362,9 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
nSuffLen = 3;
}
- TCHAR* szFileMask = reinterpret_cast< TCHAR* >( rtl_allocateMemory( sizeof( TCHAR ) * ( nLen + nSuffLen + 1 ) ) );
+ WCHAR* szFileMask = reinterpret_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) );
- _tcscpy( szFileMask, reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pPath ) ) );
+ _tcscpy( szFileMask, rtl_uString_getStr( pPath ) );
_tcscat( szFileMask, pSuffix );
pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
@@ -375,7 +375,7 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
if ( GetLastError() != ERROR_NO_MORE_FILES )
{
HeapFree(GetProcessHeap(), 0, pDirectory);
- pDirectory = NULL;
+ pDirectory = nullptr;
}
}
rtl_freeMemory(szFileMask);
@@ -441,13 +441,13 @@ static BOOL WINAPI CloseDirectory(HANDLE hDirectory)
static oslFileError osl_openLocalRoot(
rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
{
- rtl_uString *strSysPath = NULL;
+ rtl_uString *strSysPath = nullptr;
oslFileError error;
if ( !pDirectory )
return osl_File_E_INVAL;
- *pDirectory = NULL;
+ *pDirectory = nullptr;
error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False );
if ( osl_File_E_None == error )
@@ -516,7 +516,7 @@ static oslFileError SAL_CALL osl_openFileDirectory(
if ( !pDirectory )
return osl_File_E_INVAL;
- *pDirectory = NULL;
+ *pDirectory = nullptr;
Directory_Impl *pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
@@ -569,7 +569,7 @@ static oslFileError SAL_CALL osl_openNetworkServer(
ZeroMemory( &aNetResource, sizeof(aNetResource) );
- aNetResource.lpRemoteName = reinterpret_cast<LPWSTR>(strSysDirPath->buffer);
+ aNetResource.lpRemoteName = strSysDirPath->buffer;
dwError = WNetOpenEnumW(
RESOURCE_GLOBALNET,
@@ -600,7 +600,7 @@ static DWORD create_dir_with_callback(
// user specified callback function. On success
// the function returns ERROR_SUCCESS else a Win32 error code.
- BOOL bCreated = CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( dir_path )), NULL );
+ BOOL bCreated = CreateDirectoryW( rtl_uString_getStr( dir_path ), nullptr );
if ( bCreated )
{
@@ -668,7 +668,7 @@ oslFileError SAL_CALL osl_createDirectoryPath(
oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
void* pData)
{
- if (aDirectoryUrl == NULL)
+ if (aDirectoryUrl == nullptr)
return osl_File_E_INVAL;
rtl::OUString sys_path;
@@ -695,12 +695,12 @@ oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32)
{
- rtl_uString *strSysPath = NULL;
+ rtl_uString *strSysPath = nullptr;
oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
if ( osl_File_E_None == error )
{
- BOOL bCreated = CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL );
+ BOOL bCreated = CreateDirectoryW( rtl_uString_getStr( strSysPath ), nullptr );
if ( !bCreated )
{
@@ -730,12 +730,12 @@ oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32)
oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath)
{
- rtl_uString *strSysPath = NULL;
+ rtl_uString *strSysPath = nullptr;
oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
if ( osl_File_E_None == error )
{
- if ( RemoveDirectory( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
+ if ( RemoveDirectory( rtl_uString_getStr( strSysPath ) ) )
error = osl_File_E_None;
else
error = oslTranslateFileError( GetLastError() );
@@ -753,7 +753,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect
error = osl_openLocalRoot( strDirectoryPath, pDirectory );
else
{
- rtl_uString *strSysDirectoryPath = NULL;
+ rtl_uString *strSysDirectoryPath = nullptr;
DWORD dwPathType;
error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False );
@@ -761,7 +761,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect
if ( osl_File_E_None != error )
return error;
- dwPathType = IsValidFilePath( strSysDirectoryPath, NULL, VALIDATEPATH_NORMAL, NULL );
+ dwPathType = IsValidFilePath( strSysDirectoryPath, nullptr, VALIDATEPATH_NORMAL, nullptr );
if ( dwPathType & PATHTYPE_IS_SERVER )
{
@@ -779,14 +779,14 @@ static oslFileError SAL_CALL osl_getNextNetResource(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ )
{
Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
+ DirectoryItem_Impl *pItemImpl = nullptr;
BYTE buffer[16384];
LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer;
DWORD dwError, dwCount, dwBufSize;
if ( !pItem )
return osl_File_E_INVAL;
- *pItem = NULL;
+ *pItem = nullptr;
if ( !pDirImpl )
return osl_File_E_INVAL;
@@ -824,12 +824,12 @@ static oslFileError SAL_CALL osl_getNextDrive(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ )
{
Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
+ DirectoryItem_Impl *pItemImpl = nullptr;
BOOL fSuccess;
if ( !pItem )
return osl_File_E_INVAL;
- *pItem = NULL;
+ *pItem = nullptr;
if ( !pDirImpl )
return osl_File_E_INVAL;
@@ -865,12 +865,12 @@ static oslFileError SAL_CALL osl_getNextFileItem(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/)
{
Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
+ DirectoryItem_Impl *pItemImpl = nullptr;
BOOL fFound;
if ( !pItem )
return osl_File_E_INVAL;
- *pItem = NULL;
+ *pItem = nullptr;
if ( !pDirImpl )
return osl_File_E_INVAL;
@@ -888,7 +888,7 @@ static oslFileError SAL_CALL osl_getNextFileItem(
pItemImpl->nRefCount = 1;
rtl_uString* pTmpFileName = 0;
- rtl_uString_newFromStr( &pTmpFileName, reinterpret_cast<const sal_Unicode *>(pItemImpl->FindData.cFileName) );
+ rtl_uString_newFromStr( &pTmpFileName, pItemImpl->FindData.cFileName );
rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName );
rtl_uString_release( pTmpFileName );
@@ -918,7 +918,7 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(
if ( !pItem )
return osl_File_E_INVAL;
- *pItem = NULL;
+ *pItem = nullptr;
if ( !pDirImpl )
return osl_File_E_INVAL;
@@ -986,7 +986,7 @@ typedef enum _PATHTYPE
oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem)
{
oslFileError error = osl_File_E_None;
- rtl_uString* strSysFilePath = NULL;
+ rtl_uString* strSysFilePath = nullptr;
PATHTYPE type = PATHTYPE_FILE;
DWORD dwPathType;
@@ -995,14 +995,14 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
if ( !pItem )
return osl_File_E_INVAL;
- *pItem = NULL;
+ *pItem = nullptr;
error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False );
if ( osl_File_E_None != error )
return error;
- dwPathType = IsValidFilePath( strSysFilePath, NULL, VALIDATEPATH_NORMAL, NULL );
+ dwPathType = IsValidFilePath( strSysFilePath, nullptr, VALIDATEPATH_NORMAL, nullptr );
if ( dwPathType & PATHTYPE_IS_VOLUME )
type = PATHTYPE_VOLUME;
@@ -1059,7 +1059,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
- _tcscpy( pItemImpl->cDriveString, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
+ _tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer );
pItemImpl->cDriveString[0] = toupper( pItemImpl->cDriveString[0] );
if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' )
@@ -1079,7 +1079,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' )
rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 );
- hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)), &aFindData );
+ hFind = FindFirstFile( rtl_uString_getStr(strSysFilePath), &aFindData );
if ( hFind != INVALID_HANDLE_VALUE )
{
@@ -1178,10 +1178,10 @@ bool is_floppy_volume_mount_point(const rtl::OUString& path)
rtl::OUString p(path);
osl::systemPathEnsureSeparator(p);
- TCHAR vn[51];
- if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, SAL_N_ELEMENTS(vn)))
+ WCHAR vn[51];
+ if (GetVolumeNameForVolumeMountPoint(p.getStr(), vn, SAL_N_ELEMENTS(vn)))
{
- TCHAR vnfloppy[51];
+ WCHAR vnfloppy[51];
if (is_floppy_A_present() &&
GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, SAL_N_ELEMENTS(vnfloppy)) &&
(0 == wcscmp(vn, vnfloppy)))
@@ -1218,13 +1218,13 @@ static bool is_volume_mount_point(const rtl::OUString& path)
if (!is_floppy_drive(p))
{
- DWORD fattr = GetFileAttributes(reinterpret_cast<LPCTSTR>(p.getStr()));
+ DWORD fattr = GetFileAttributes(p.getStr());
if ((INVALID_FILE_ATTRIBUTES != fattr) &&
(FILE_ATTRIBUTE_REPARSE_POINT & fattr))
{
WIN32_FIND_DATA find_data;
- HANDLE h_find = FindFirstFile(reinterpret_cast<LPCTSTR>(p.getStr()), &find_data);
+ HANDLE h_find = FindFirstFile(p.getStr(), &find_data);
if (IsValidHandle(h_find) &&
(FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) &&
@@ -1242,13 +1242,13 @@ static bool is_volume_mount_point(const rtl::OUString& path)
static UINT get_volume_mount_point_drive_type(const rtl::OUString& path)
{
if (0 == path.getLength())
- return GetDriveType(NULL);
+ return GetDriveType(nullptr);
rtl::OUString p(path);
osl::systemPathEnsureSeparator(p);
- TCHAR vn[51];
- if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, SAL_N_ELEMENTS(vn)))
+ WCHAR vn[51];
+ if (GetVolumeNameForVolumeMountPoint(p.getStr(), vn, SAL_N_ELEMENTS(vn)))
return GetDriveType(vn);
return DRIVE_NO_ROOT_DIR;
@@ -1268,7 +1268,7 @@ static oslFileError osl_get_drive_type(
if (is_volume_mount_point(path))
drive_type = get_volume_mount_point_drive_type(path);
else
- drive_type = GetDriveType(reinterpret_cast<LPCTSTR>(path.getStr()));
+ drive_type = GetDriveType(path.getStr());
if (DRIVE_NO_ROOT_DIR == drive_type)
return oslTranslateFileError(ERROR_INVALID_DRIVE);
@@ -1317,10 +1317,10 @@ static void get_volume_space_information(
const rtl::OUString& path, oslVolumeInfo *pInfo)
{
BOOL ret = GetDiskFreeSpaceEx(
- reinterpret_cast<LPCTSTR>(path.getStr()),
+ path.getStr(),
(PULARGE_INTEGER)&(pInfo->uFreeSpace),
(PULARGE_INTEGER)&(pInfo->uTotalSpace),
- NULL);
+ nullptr);
if (ret)
{
@@ -1364,7 +1364,7 @@ static oslFileError get_filesystem_attributes(
DWORD mcl;
DWORD flags;
- LPCTSTR pszPath = reinterpret_cast<LPCTSTR>(path.getStr());
+ LPCWSTR pszPath = path.getStr();
if (GetVolumeInformation(pszPath, vn, MAX_PATH+1, &serial, &mcl, &flags, fsn, MAX_PATH+1))
{
// Currently sal does not use this value, instead MAX_PATH is used
@@ -1376,7 +1376,7 @@ static oslFileError get_filesystem_attributes(
pInfo->uMaxPathLength = MAX_PATH;
pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName;
- rtl_uString_newFromStr(&pInfo->ustrFileSystemName, reinterpret_cast<const sal_Unicode*>(fsn));
+ rtl_uString_newFromStr(&pInfo->ustrFileSystemName, fsn);
// volumes (even NTFS) will always be considered case
// insensitive because the Win32 API is not able to
@@ -1458,8 +1458,8 @@ static oslFileError SAL_CALL osl_getDriveInfo(
oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
{
DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
- TCHAR cDrive[3] = TEXT("A:");
- TCHAR cRoot[4] = TEXT("A:\\");
+ WCHAR cDrive[3] = TEXT("A:");
+ WCHAR cRoot[4] = TEXT("A:\\");
if ( !pItemImpl )
return osl_File_E_INVAL;
@@ -1480,9 +1480,9 @@ static oslFileError SAL_CALL osl_getDriveInfo(
LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' );
if ( lpLastBkSlash )
- rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 );
+ rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, &lpFirstBkSlash[1], lpLastBkSlash - lpFirstBkSlash - 1 );
else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, &lpFirstBkSlash[1] );
pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
}
}
@@ -1490,44 +1490,44 @@ static oslFileError SAL_CALL osl_getDriveInfo(
{
case DRIVE_REMOTE:
{
- TCHAR szBuffer[1024];
+ WCHAR szBuffer[1024];
DWORD const dwBufsizeConst = SAL_N_ELEMENTS(szBuffer);
DWORD dwBufsize = dwBufsizeConst;
DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize );
if ( NO_ERROR == dwResult )
{
- TCHAR szFileName[dwBufsizeConst + 16];
+ WCHAR szFileName[dwBufsizeConst + 16];
swprintf( szFileName, L"%s [%s]", cDrive, szBuffer );
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, szFileName );
}
else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, cDrive );
}
pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
break;
case DRIVE_FIXED:
{
- TCHAR szVolumeNameBuffer[1024];
+ WCHAR szVolumeNameBuffer[1024];
DWORD const dwBufsizeConst = SAL_N_ELEMENTS(szVolumeNameBuffer);
- if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, dwBufsizeConst, NULL, NULL, NULL, NULL, 0 ) )
+ if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, dwBufsizeConst, nullptr, nullptr, nullptr, nullptr, 0 ) )
{
- TCHAR szFileName[dwBufsizeConst + 16];
+ WCHAR szFileName[dwBufsizeConst + 16];
swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer );
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, szFileName );
}
else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, cDrive );
}
pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
break;
case DRIVE_CDROM:
case DRIVE_REMOVABLE:
pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cRoot) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, cRoot );
break;
case DRIVE_UNKNOWN:
default:
@@ -1540,9 +1540,9 @@ static oslFileError SAL_CALL osl_getDriveInfo(
if ( uFieldMask & osl_FileStatus_Mask_FileURL )
{
- rtl_uString *ustrSystemPath = NULL;
+ rtl_uString *ustrSystemPath = nullptr;
- rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) );
+ rtl_uString_newFromStr( &ustrSystemPath, pItemImpl->cDriveString );
oslFileError error = osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
rtl_uString_release( ustrSystemPath );
if (error != osl_File_E_None)
@@ -1603,7 +1603,7 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( uFieldMask & osl_FileStatus_Mask_Validate )
{
- HANDLE hFind = FindFirstFile( reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pItemImpl->m_pFullPath ) ), &pItemImpl->FindData );
+ HANDLE hFind = FindFirstFile( rtl_uString_getStr( pItemImpl->m_pFullPath ), &pItemImpl->FindData );
if ( hFind != INVALID_HANDLE_VALUE )
FindClose( hFind );
@@ -1642,7 +1642,7 @@ oslFileError SAL_CALL osl_getFileStatus(
/* Most of the fields are already set, regardless of requiered fields */
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(pItemImpl->FindData.cFileName) );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, pItemImpl->FindData.cFileName );
pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) &&
@@ -1675,8 +1675,8 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( !pItemImpl->bFullPathNormalized )
{
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
- sal_uInt32 nNewLen = GetCaseCorrectPathName( reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pItemImpl->m_pFullPath ) ),
- ::osl::mingw_reinterpret_cast<LPTSTR>( aBuffer ),
+ sal_uInt32 nNewLen = GetCaseCorrectPathName( rtl_uString_getStr( pItemImpl->m_pFullPath ),
+ ::osl::mingw_reinterpret_cast<LPWSTR>( aBuffer ),
aBuffer.getBufSizeInSymbols(),
sal_True );
@@ -1703,7 +1703,7 @@ oslFileError SAL_CALL osl_setFileAttributes(
sal_uInt64 uAttributes )
{
oslFileError error;
- rtl_uString *ustrSysPath = NULL;
+ rtl_uString *ustrSysPath = nullptr;
DWORD dwFileAttributes;
BOOL fSuccess;
@@ -1713,7 +1713,7 @@ oslFileError SAL_CALL osl_setFileAttributes(
if ( osl_File_E_None != error )
return error;
- dwFileAttributes = GetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)) );
+ dwFileAttributes = GetFileAttributes( rtl_uString_getStr(ustrSysPath) );
if ( (DWORD)-1 != dwFileAttributes )
{
@@ -1725,7 +1725,7 @@ oslFileError SAL_CALL osl_setFileAttributes(
if ( uAttributes & osl_File_Attribute_Hidden )
dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
- fSuccess = SetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)), dwFileAttributes );
+ fSuccess = SetFileAttributes( rtl_uString_getStr(ustrSysPath), dwFileAttributes );
}
else
fSuccess = FALSE;
@@ -1745,10 +1745,10 @@ oslFileError SAL_CALL osl_setFileTime(
const TimeValue *aLastWriteTime)
{
oslFileError error;
- rtl_uString *sysPath=NULL;
- FILETIME *lpCreationTime=NULL;
- FILETIME *lpLastAccessTime=NULL;
- FILETIME *lpLastWriteTime=NULL;
+ rtl_uString *sysPath=nullptr;
+ FILETIME *lpCreationTime=nullptr;
+ FILETIME *lpLastAccessTime=nullptr;
+ FILETIME *lpLastWriteTime=nullptr;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
@@ -1760,7 +1760,7 @@ oslFileError SAL_CALL osl_setFileTime(
if (error==osl_File_E_INVAL)
return error;
- hFile=CreateFileW(reinterpret_cast<LPCWSTR>(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile=CreateFileW(rtl_uString_getStr(sysPath), GENERIC_WRITE, 0, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
rtl_uString_release(sysPath);
if (hFile==INVALID_HANDLE_VALUE)
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index dda005b0044c..74f0f97d91c8 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -46,12 +46,12 @@ extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */
oslMutex g_CurrentDirectoryMutex = 0;
static BOOL IsValidFilePathComponent(
- LPCTSTR lpComponent, LPCTSTR *lppComponentEnd, DWORD dwFlags)
+ LPCWSTR lpComponent, LPCWSTR *lppComponentEnd, DWORD dwFlags)
{
- LPCTSTR lpComponentEnd = NULL;
- LPCTSTR lpCurrent = lpComponent;
+ LPCWSTR lpComponentEnd = nullptr;
+ LPCWSTR lpCurrent = lpComponent;
BOOL fValid = TRUE; /* Assume success */
- TCHAR cLast = 0;
+ WCHAR cLast = 0;
/* Path component length must not exceed MAX_PATH even if long path with "\\?\" prefix is used */
@@ -147,7 +147,7 @@ static BOOL IsValidFilePathComponent(
/*
if ( fValid )
{
- LPCTSTR alpDeviceNames[] =
+ LPCWSTR alpDeviceNames[] =
{
TEXT("CON"),
TEXT("PRN"),
@@ -174,9 +174,9 @@ static BOOL IsValidFilePathComponent(
TEXT("COM9")
};
- TCHAR szComponent[MAX_PATH];
+ WCHAR szComponent[MAX_PATH];
int nComponentLength;
- LPCTSTR lpDot;
+ LPCWSTR lpDot;
int i;
// A device name with an extension is also invalid
@@ -190,7 +190,7 @@ static BOOL IsValidFilePathComponent(
_tcsncpy( szComponent, lpComponent, nComponentLength );
szComponent[nComponentLength] = 0;
- for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCTSTR); i++ )
+ for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCWSTR); i++ )
{
if ( 0 == _tcsicmp( szComponent, alpDeviceNames[i] ) )
{
@@ -208,9 +208,9 @@ static BOOL IsValidFilePathComponent(
if ( lpComponentEnd - lpComponent < 1 )
fValid = FALSE;
- // If we reached the end of the string NULL is returned
+ // If we reached the end of the string nullptr is returned
else if ( !*lpComponentEnd )
- lpComponentEnd = NULL;
+ lpComponentEnd = nullptr;
}
@@ -222,10 +222,10 @@ static BOOL IsValidFilePathComponent(
#define CHARSET_SEPARATOR TEXT("\\/")
-DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected)
+DWORD IsValidFilePath(rtl_uString *path, LPCWSTR *lppError, DWORD dwFlags, rtl_uString **corrected)
{
- LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer);
- LPCTSTR lpComponent = lpszPath;
+ LPCWSTR lpszPath = path->buffer;
+ LPCWSTR lpComponent = lpszPath;
BOOL fValid = TRUE;
DWORD dwPathType = PATHTYPE_ERROR;
sal_Int32 nLength = rtl_uString_getLength( path );
@@ -238,13 +238,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, reinterpret_cast<const sal_Unicode *>(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, 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, reinterpret_cast<const sal_Unicode *>(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, 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;
@@ -279,7 +279,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
if ( fValid )
{
if ( lpComponent && !*++lpComponent )
- lpComponent = NULL;
+ lpComponent = nullptr;
if ( !lpComponent )
{
@@ -295,7 +295,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
if ( fValid && (!lpComponent || !*++lpComponent ) )
{
- lpComponent = NULL;
+ lpComponent = nullptr;
dwPathType |= PATHTYPE_IS_VOLUME;
}
}
@@ -314,7 +314,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
if ( fValid && !*lpComponent )
{
- lpComponent = NULL;
+ lpComponent = nullptr;
dwPathType |= PATHTYPE_IS_VOLUME;
}
}
@@ -329,7 +329,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
{
lpComponent++;
if ( !*lpComponent )
- lpComponent = NULL;
+ lpComponent = nullptr;
}
dwPathType = PATHTYPE_RELATIVE;
@@ -345,11 +345,11 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
while ( fValid && lpComponent )
{
// Correct path by merging consecutive slashes:
- if (*lpComponent == '\\' && corrected != NULL) {
+ if (*lpComponent == '\\' && corrected != nullptr) {
sal_Int32 i = lpComponent - lpszPath;
- rtl_uString_newReplaceStrAt(corrected, path, i, 1, NULL);
+ rtl_uString_newReplaceStrAt(corrected, path, i, 1, nullptr);
//TODO: handle out-of-memory
- lpszPath = reinterpret_cast< LPCTSTR >((*corrected)->buffer);
+ lpszPath = (*corrected)->buffer;
lpComponent = lpszPath + i;
}
@@ -362,7 +362,7 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
/* If the string behind the backslash is empty, we've done */
if ( !*lpComponent )
- lpComponent = NULL;
+ lpComponent = nullptr;
}
}
@@ -379,16 +379,16 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
return fValid ? dwPathType : PATHTYPE_ERROR;
}
-static sal_Int32 PathRemoveFileSpec(LPTSTR lpPath, LPTSTR lpFileName, sal_Int32 nFileBufLen )
+static sal_Int32 PathRemoveFileSpec(LPWSTR lpPath, LPWSTR lpFileName, sal_Int32 nFileBufLen )
{
sal_Int32 nRemoved = 0;
if ( nFileBufLen )
{
lpFileName[0] = 0;
- LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
- LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' );
- LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
+ LPWSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
+ LPWSTR lpLastSlash = _tcsrchr( lpPath, '/' );
+ LPWSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
if ( lpLastDelimiter )
{
@@ -415,9 +415,9 @@ static sal_Int32 PathRemoveFileSpec(LPTSTR lpPath, LPTSTR lpFileName, sal_Int32
}
// Undocumented in SHELL32.DLL ordinal 32
-static LPTSTR PathAddBackslash(LPTSTR lpPath, sal_Int32 nBufLen)
+static LPWSTR PathAddBackslash(LPWSTR lpPath, sal_Int32 nBufLen)
{
- LPTSTR lpEndPath = NULL;
+ LPWSTR lpEndPath = nullptr;
if ( lpPath )
{
@@ -435,7 +435,7 @@ static LPTSTR PathAddBackslash(LPTSTR lpPath, sal_Int32 nBufLen)
// Same as GetLongPathName but also 95/NT4
static DWORD GetCaseCorrectPathNameEx(
- LPTSTR lpszPath, // path buffer to convert
+ LPWSTR lpszPath, // path buffer to convert
DWORD cchBuffer, // size of path buffer
DWORD nSkipLevels,
BOOL bCheckExistence )
@@ -519,8 +519,8 @@ static DWORD GetCaseCorrectPathNameEx(
}
DWORD GetCaseCorrectPathName(
- LPCTSTR lpszShortPath, // file name
- LPTSTR lpszLongPath, // path buffer
+ LPCWSTR lpszShortPath, // file name
+ LPWSTR lpszLongPath, // path buffer
DWORD cchBuffer, // size of path buffer
BOOL bCheckExistence
)
@@ -583,7 +583,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR
aToken[1] = *pSrc++;
aToken[2] = 0;
- aChar = (sal_Char)strtoul( aToken, NULL, 16 );
+ aChar = (sal_Char)strtoul( aToken, nullptr, 16 );
/* The chars are path delimiters and must not be encoded */
@@ -621,7 +621,7 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
{
/* Encode non ascii characters within the URL */
- rtl_String *strUTF8 = NULL;
+ rtl_String *strUTF8 = nullptr;
sal_Char *pszEncodedURL;
const sal_Char *pURLScan;
sal_Char *pURLDest;
@@ -687,9 +687,9 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
{
- rtl_String *strUTF8 = NULL;
- rtl_uString *strDecodedURL = NULL;
- rtl_uString *strTempPath = NULL;
+ rtl_String *strUTF8 = nullptr;
+ rtl_uString *strDecodedURL = nullptr;
+ rtl_uString *strTempPath = nullptr;
sal_uInt32 nDecodedLen;
sal_Bool bValidEncoded;
oslFileError nError = osl_File_E_INVAL; /* Assume failure */
@@ -739,7 +739,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
/* Indicates local root */
if ( nDecodedLen == nSkip )
- rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 );
+ rtl_uString_newFromStr_WithLength( &strTempPath, 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 */
@@ -750,23 +750,23 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
else
{
::osl::LongPathBuffer< sal_Unicode > aBuf( MAX_LONG_PATH );
- sal_uInt32 nNewLen = GetCaseCorrectPathName( reinterpret_cast<LPCTSTR>(pDecodedURL + nSkip),
- ::osl::mingw_reinterpret_cast<LPTSTR>(aBuf),
+ sal_uInt32 nNewLen = GetCaseCorrectPathName( pDecodedURL + nSkip,
+ ::osl::mingw_reinterpret_cast<LPWSTR>(aBuf),
aBuf.getBufSizeInSymbols(),
sal_False );
if ( nNewLen <= MAX_PATH - 12
- || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, reinterpret_cast<const sal_Unicode*>(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, reinterpret_cast<const sal_Unicode*>(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, 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 ) )
{
rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen );
}
else if ( pDecodedURL[nSkip] == (sal_Unicode)'\\' && pDecodedURL[nSkip+1] == (sal_Unicode)'\\' )
{
/* it should be an UNC path, use the according prefix */
- rtl_uString *strSuffix = NULL;
- rtl_uString *strPrefix = NULL;
- rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 );
+ 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( &strSuffix, aBuf + 2, nNewLen - 2 );
rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
@@ -776,9 +776,9 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
}
else
{
- rtl_uString *strSuffix = NULL;
- rtl_uString *strPrefix = NULL;
- rtl_uString_newFromStr_WithLength( &strPrefix, reinterpret_cast<const sal_Unicode*>(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 );
+ 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( &strSuffix, aBuf, nNewLen );
rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
@@ -789,7 +789,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
}
}
- if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
+ if ( IsValidFilePath( strTempPath, nullptr, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
nError = osl_File_E_None;
}
else if ( bAllowRelative ) /* This maybe a relative file URL */
@@ -797,7 +797,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
/* In future the relative path could be converted to absolute if it is too long */
rtl_uString_assign( &strTempPath, strDecodedURL );
- if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
+ if ( IsValidFilePath( strTempPath, nullptr, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
nError = osl_File_E_None;
}
else
@@ -824,19 +824,19 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL )
{
oslFileError nError = osl_File_E_INVAL; /* Assume failure */
- rtl_uString *strTempURL = NULL;
+ rtl_uString *strTempURL = nullptr;
DWORD dwPathType = PATHTYPE_ERROR;
if (strPath)
- dwPathType = IsValidFilePath(strPath, NULL, VALIDATEPATH_ALLOW_RELATIVE, NULL);
+ dwPathType = IsValidFilePath(strPath, nullptr, VALIDATEPATH_ALLOW_RELATIVE, nullptr);
if (dwPathType)
{
- rtl_uString *strTempPath = NULL;
+ rtl_uString *strTempPath = nullptr;
if ( dwPathType & PATHTYPE_IS_LONGPATH )
{
- rtl_uString *strBuffer = NULL;
+ rtl_uString *strBuffer = nullptr;
sal_uInt32 nIgnore = 0;
sal_uInt32 nLength = 0;
@@ -906,7 +906,7 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString**
if ( osl_File_E_None == nError )
{
- rtl_String *strEncodedURL = NULL;
+ rtl_String *strEncodedURL = nullptr;
/* Encode the URL */
_osl_encodeURL( strTempURL, &strEncodedURL );
@@ -943,8 +943,8 @@ oslFileError SAL_CALL osl_searchFileURL(
rtl_uString *ustrSystemSearchPath,
rtl_uString **pustrPath)
{
- rtl_uString *ustrUNCPath = NULL;
- rtl_uString *ustrSysPath = NULL;
+ rtl_uString *ustrUNCPath = nullptr;
+ rtl_uString *ustrSysPath = nullptr;
oslFileError error;
/* First try to interpret the file name as an URL even a relative one */
@@ -959,8 +959,8 @@ oslFileError SAL_CALL osl_searchFileURL(
{
DWORD nBufferLength;
DWORD dwResult;
- LPTSTR lpBuffer = NULL;
- LPTSTR lpszFilePart;
+ LPWSTR lpBuffer = nullptr;
+ LPWSTR lpszFilePart;
/* Repeat calling SearchPath ...
Start with MAX_PATH for the buffer. In most cases this
@@ -969,18 +969,18 @@ oslFileError SAL_CALL osl_searchFileURL(
do
{
- /* If search path is empty use a NULL pointer instead according to MSDN documentation of SearchPath */
- LPCTSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? reinterpret_cast<LPCTSTR>(ustrSystemSearchPath->buffer) : NULL;
- LPCTSTR lpszSearchFile = reinterpret_cast<LPCTSTR>(ustrSysPath->buffer);
+ /* 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;
/* 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 */
nBufferLength = dwResult + 1;
lpBuffer = lpBuffer ?
- reinterpret_cast<LPTSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(TCHAR))) :
- reinterpret_cast<LPTSTR>(rtl_allocateMemory(nBufferLength * sizeof(TCHAR)));
+ reinterpret_cast<LPWSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(WCHAR))) :
+ reinterpret_cast<LPWSTR>(rtl_allocateMemory(nBufferLength * sizeof(WCHAR)));
- dwResult = SearchPath( lpszSearchPath, lpszSearchFile, NULL, nBufferLength, lpBuffer, &lpszFilePart );
+ dwResult = SearchPath( lpszSearchPath, lpszSearchFile, nullptr, nBufferLength, lpBuffer, &lpszFilePart );
} while ( dwResult && dwResult >= nBufferLength );
/* ... until an error occurs or buffer is large enough.
@@ -988,7 +988,7 @@ oslFileError SAL_CALL osl_searchFileURL(
if ( dwResult )
{
- rtl_uString_newFromStr( &ustrSysPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) );
+ rtl_uString_newFromStr( &ustrSysPath, lpBuffer );
error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath );
}
else
@@ -999,7 +999,7 @@ oslFileError SAL_CALL osl_searchFileURL(
/* something went wrong, perhaps the path was absolute */
error = oslTranslateFileError( GetLastError() );
- hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(ustrSysPath->buffer), &aFindFileData );
+ hFind = FindFirstFile( ustrSysPath->buffer, &aFindFileData );
if ( IsValidHandle(hFind) )
{
@@ -1023,8 +1023,8 @@ oslFileError SAL_CALL osl_searchFileURL(
oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL )
{
oslFileError eError;
- rtl_uString *ustrRelSysPath = NULL;
- rtl_uString *ustrBaseSysPath = NULL;
+ rtl_uString *ustrRelSysPath = nullptr;
+ rtl_uString *ustrBaseSysPath = nullptr;
if ( ustrBaseURL && ustrBaseURL->length )
{
@@ -1043,7 +1043,7 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
{
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
::osl::LongPathBuffer< sal_Unicode > aCurrentDir( MAX_LONG_PATH );
- LPTSTR lpFilePart = NULL;
+ LPWSTR lpFilePart = nullptr;
DWORD dwResult;
/*@@@ToDo
@@ -1058,10 +1058,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( reinterpret_cast<LPCWSTR>(ustrBaseSysPath->buffer) );
+ SetCurrentDirectoryW( ustrBaseSysPath->buffer );
}
- dwResult = GetFullPathNameW( reinterpret_cast<LPCWSTR>(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), &lpFilePart );
+ dwResult = GetFullPathNameW( ustrRelSysPath->buffer, aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), &lpFilePart );
if ( ustrBaseSysPath )
{
@@ -1076,7 +1076,7 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
eError = osl_File_E_INVAL;
else
{
- rtl_uString *ustrAbsSysPath = NULL;
+ rtl_uString *ustrAbsSysPath = nullptr;
rtl_uString_newFromStr( &ustrAbsSysPath, aBuffer );
diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h
index 9f7a37ffac0f..0f51b4c9b50a 100644
--- a/sal/osl/w32/file_url.h
+++ b/sal/osl/w32/file_url.h
@@ -58,14 +58,14 @@ extern "C" {
DWORD IsValidFilePath (
rtl_uString * path,
- LPCTSTR * lppError,
+ LPCWSTR * lppError,
DWORD dwFlags,
rtl_uString ** corrected
);
DWORD GetCaseCorrectPathName (
- LPCTSTR lpszShortPath, // file name
- LPTSTR lpszLongPath, // path buffer
+ LPCWSTR lpszShortPath, // file name
+ LPWSTR lpszLongPath, // path buffer
DWORD cchBuffer, // size of path buffer
BOOL bCheckExistence
);
diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx
index e560a7bb571e..c0d5673faf38 100644
--- a/sal/osl/w32/procimpl.cxx
+++ b/sal/osl/w32/procimpl.cxx
@@ -120,12 +120,12 @@ namespace /* private */
{
// GetEnvironmentStrings returns a sorted list, Windows
// sorts environment variables upper case
- LPTSTR env = reinterpret_cast<LPTSTR>(GetEnvironmentStrings());
- LPTSTR p = env;
+ LPWSTR env = GetEnvironmentStrings();
+ LPWSTR p = env;
while (size_t l = _tcslen(p))
{
- environment->push_back(reinterpret_cast<const sal_Unicode*>(p));
+ environment->push_back(p);
p += l + 1;
}
FreeEnvironmentStrings(env);
@@ -221,7 +221,7 @@ namespace /* private */
bool b_read_pipe_inheritable,
PHANDLE p_write_pipe,
bool b_write_pipe_inheritable,
- LPVOID p_security_descriptor = NULL,
+ LPVOID p_security_descriptor = nullptr,
DWORD pipe_size = 0)
{
SECURITY_ATTRIBUTES sa;
@@ -230,7 +230,7 @@ namespace /* private */
sa.bInheritHandle = b_read_pipe_inheritable || b_write_pipe_inheritable;
BOOL bRet = FALSE;
- HANDLE hTemp = NULL;
+ HANDLE hTemp = nullptr;
if (!b_read_pipe_inheritable && b_write_pipe_inheritable)
{
@@ -295,7 +295,7 @@ namespace /* private */
std::vector<sal_Unicode> vec(path.getLength() + 1);
//GetShortPathNameW only works if the file can be found!
const DWORD len = GetShortPathNameW(
- reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
+ path.getStr(), &vec[0], path.getLength() + 1);
if (!len && GetLastError() == ERROR_FILE_NOT_FOUND
&& extension.getLength())
@@ -304,7 +304,7 @@ namespace /* private */
std::vector<sal_Unicode> vec2(
extPath.getLength() + 1);
const DWORD len2 = GetShortPathNameW(
- reinterpret_cast<LPCWSTR>(extPath.getStr()), reinterpret_cast<LPWSTR>(&vec2[0]), extPath.getLength() + 1);
+ extPath.getStr(), &vec2[0], extPath.getLength() + 1);
ret = rtl::OUString(&vec2[0], len2);
}
else
@@ -334,7 +334,7 @@ namespace /* private */
rtl::OUString exe_url = exe_name;
if (search_path)
- osl_searchFileURL(exe_name.pData, NULL, &exe_url.pData);
+ osl_searchFileURL(exe_name.pData, nullptr, &exe_url.pData);
rtl::OUString exe_path;
if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(exe_url, exe_path))
@@ -403,7 +403,7 @@ oslProcessError SAL_CALL osl_executeProcess(
strEnvironmentVars,
nEnvironmentVars,
pProcess,
- NULL, NULL, NULL );
+ nullptr, nullptr, nullptr );
}
oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
@@ -426,7 +426,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
if (0 == exe_path.getLength())
return osl_Process_E_NotFound;
- if (pProcess == NULL)
+ if (pProcess == nullptr)
return osl_Process_E_InvalidError;
DWORD flags = NORMAL_PRIORITY_CLASS;
@@ -452,10 +452,10 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
command_line.append(exe_path);
- /* Add remaining arguments to command line. If ustrImageName is NULL
+ /* Add remaining arguments to command line. If ustrImageName is nullptr
the first parameter is the name of the executable so we have to
start at 1 instead of 0 */
- for (sal_uInt32 n = (NULL != ustrImageName) ? 0 : 1; n < nArguments; n++)
+ for (sal_uInt32 n = (nullptr != ustrImageName) ? 0 : 1; n < nArguments; n++)
{
command_line.appendAscii(SPACE);
@@ -467,7 +467,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
}
environment_container_t environment;
- LPVOID p_environment = NULL;
+ LPVOID p_environment = nullptr;
if (nEnvironmentVars && ustrEnvironmentVars)
{
@@ -483,7 +483,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
if (ustrDirectory && ustrDirectory->length && (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(ustrDirectory, cwd)))
return osl_Process_E_InvalidError;
- LPCWSTR p_cwd = (cwd.getLength()) ? reinterpret_cast<LPCWSTR>(cwd.getStr()) : NULL;
+ LPCWSTR p_cwd = (cwd.getLength()) ? cwd.getStr() : nullptr;
if ((Options & osl_Process_DETACHED) && !(flags & CREATE_NEW_CONSOLE))
flags |= DETACHED_PROCESS;
@@ -496,18 +496,18 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
startup_info.lpDesktop = const_cast<LPWSTR>(L"");
/* Create pipes for redirected IO */
- HANDLE hInputRead = NULL;
- HANDLE hInputWrite = NULL;
+ HANDLE hInputRead = nullptr;
+ HANDLE hInputWrite = nullptr;
if (pProcessInputWrite && create_pipe(&hInputRead, true, &hInputWrite, false))
startup_info.hStdInput = hInputRead;
- HANDLE hOutputRead = NULL;
- HANDLE hOutputWrite = NULL;
+ HANDLE hOutputRead = nullptr;
+ HANDLE hOutputWrite = nullptr;
if (pProcessOutputRead && create_pipe(&hOutputRead, false, &hOutputWrite, true))
startup_info.hStdOutput = hOutputWrite;
- HANDLE hErrorRead = NULL;
- HANDLE hErrorWrite = NULL;
+ HANDLE hErrorRead = nullptr;
+ HANDLE hErrorWrite = nullptr;
if (pProcessErrorRead && create_pipe(&hErrorRead, false, &hErrorWrite, true))
startup_info.hStdError = hErrorWrite;
@@ -544,18 +544,18 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
PROCESS_INFORMATION process_info;
BOOL bRet = FALSE;
- if ((Security != NULL) && (((oslSecurityImpl*)Security)->m_hToken != NULL))
+ if ((Security != nullptr) && (((oslSecurityImpl*)Security)->m_hToken != nullptr))
{
bRet = CreateProcessAsUser(
((oslSecurityImpl*)Security)->m_hToken,
- NULL, const_cast<LPTSTR>(reinterpret_cast<LPCTSTR>(cmdline.getStr())), NULL, NULL,
+ nullptr, const_cast<LPWSTR>(cmdline.getStr()), nullptr, nullptr,
b_inherit_handles, flags, p_environment, p_cwd,
&startup_info, &process_info);
}
else
{
bRet = CreateProcess(
- NULL, const_cast<LPTSTR>(reinterpret_cast<LPCTSTR>(cmdline.getStr())), NULL, NULL,
+ nullptr, const_cast<LPWSTR>(cmdline.getStr()), nullptr, nullptr,
b_inherit_handles, flags, p_environment, p_cwd,
&startup_info, &process_info);
}
@@ -578,7 +578,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
oslProcessImpl* pProcImpl = reinterpret_cast<oslProcessImpl*>(
rtl_allocateMemory(sizeof(oslProcessImpl)));
- if (pProcImpl != NULL)
+ if (pProcImpl != nullptr)
{
pProcImpl->m_hProcess = process_info.hProcess;
pProcImpl->m_IdProcess = process_info.dwProcessId;