[Libreoffice-commits] core.git: external/poppler include/sal include/systools sal/osl sal/qa sal/rtl sal/systools
Stephan Bergmann
sbergman at redhat.com
Tue Oct 4 06:53:56 UTC 2016
external/poppler/poppler-snprintf.patch.1 | 6
include/sal/config.h | 2
include/systools/win32/snprintf.h | 8
sal/osl/all/log.cxx | 2
sal/osl/w32/backtrace.cxx | 8
sal/osl/w32/conditn.c | 4
sal/osl/w32/dllentry.c | 11
sal/osl/w32/file-impl.hxx | 25 +
sal/osl/w32/file.cxx | 177 ++++---
sal/osl/w32/file_dirvol.cxx | 168 +++----
sal/osl/w32/file_url.cxx | 50 +-
sal/osl/w32/file_url.h | 4
sal/osl/w32/filetime.h | 50 ++
sal/osl/w32/module.cxx | 100 ++--
sal/osl/w32/nlsupport.c | 4
sal/osl/w32/nlsupport.h | 29 +
sal/osl/w32/path_helper.cxx | 2
sal/osl/w32/path_helper.hxx | 4
sal/osl/w32/pipe.c | 18
sal/osl/w32/process.cxx | 72 +--
sal/osl/w32/procimpl.cxx | 23
sal/osl/w32/procimpl.h | 4
sal/osl/w32/profile.cxx | 574 ++++++++++++------------
sal/osl/w32/salinit.cxx | 11
sal/osl/w32/secimpl.h | 6
sal/osl/w32/security.c | 8
sal/osl/w32/signal.cxx | 2
sal/osl/w32/socket.cxx | 435 ++++++++----------
sal/osl/w32/sockimpl.h | 8
sal/osl/w32/tempfile.cxx | 41 -
sal/osl/w32/thread.c | 41 -
sal/osl/w32/thread.h | 29 +
sal/osl/w32/time.c | 10
sal/osl/w32/time.h | 27 +
sal/qa/osl/process/osl_process.cxx | 24 -
sal/qa/osl/process/osl_process_child.cxx | 2
sal/qa/osl/security/osl_Security.cxx | 33 -
sal/qa/osl/setthreadname/test-setthreadname.cxx | 2
sal/rtl/alloc_arena.cxx | 6
sal/rtl/alloc_cache.cxx | 4
sal/systools/win32/uwinapi/sntprintf.c | 6
41 files changed, 1083 insertions(+), 957 deletions(-)
New commits:
commit 974b7fe6dfa8935a2068365e416b8d886f9d2a32
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Sep 30 15:05:12 2016 +0200
clang-cl loplugin: sal
Change-Id: If04d3f07dc8bffac8887773b5424c09848cd8f1a
Reviewed-on: https://gerrit.libreoffice.org/29404
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/external/poppler/poppler-snprintf.patch.1 b/external/poppler/poppler-snprintf.patch.1
index aaced8e..f44dad5 100644
--- a/external/poppler/poppler-snprintf.patch.1
+++ b/external/poppler/poppler-snprintf.patch.1
@@ -6,7 +6,7 @@
#include <stdlib.h>
+#ifdef _WIN32
+# ifdef __MINGW32__
-+# define _SNPRINTF_DLLIMPORT
++# define LO_SNPRINTF_DLLIMPORT
+# endif
+# ifdef _MSC_VER
+# include <systools/win32/snprintf.h>
@@ -22,7 +22,7 @@
# include <shlobj.h>
# include <mbstring.h>
+# ifdef __MINGW32__
-+# define _SNPRINTF_DLLIMPORT
++# define LO_SNPRINTF_DLLIMPORT
+# endif
+# ifdef _MSC_VER
+# include <systools/win32/snprintf.h>
@@ -38,7 +38,7 @@
#include <assert.h>
+#ifdef _WIN32
+# ifdef __MINGW32__
-+# define _SNPRINTF_DLLIMPORT
++# define LO_SNPRINTF_DLLIMPORT
+# endif
+# ifdef _MSC_VER
+# include <systools/win32/snprintf.h>
diff --git a/include/sal/config.h b/include/sal/config.h
index 29fe63b..9388de9 100644
--- a/include/sal/config.h
+++ b/include/sal/config.h
@@ -45,7 +45,7 @@
/* Provide ISO C99 compatible versions of snprint and vsnprintf */
#ifdef __MINGW32__
-#define _SNPRINTF_DLLIMPORT
+#define LO_SNPRINTF_DLLIMPORT
#endif
#ifndef _SNPRINTF_H
#include <systools/win32/snprintf.h>
diff --git a/include/systools/win32/snprintf.h b/include/systools/win32/snprintf.h
index 62abfc8..4342add 100644
--- a/include/systools/win32/snprintf.h
+++ b/include/systools/win32/snprintf.h
@@ -49,8 +49,8 @@
# endif
-#ifndef _SNPRINTF_DLLIMPORT
-#define _SNPRINTF_DLLIMPORT __declspec( dllimport )
+#ifndef LO_SNPRINTF_DLLIMPORT
+#define LO_SNPRINTF_DLLIMPORT __declspec( dllimport )
#endif
#ifdef __cplusplus
@@ -73,10 +73,10 @@ extern "C" {
#if _MSC_VER < 1900
/* UNICODE version */
-_SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
+LO_SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
/* SBCS and MBCS version */
-_SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
+LO_SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
#endif
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index da167a7..afde142 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -44,7 +44,7 @@
// sal/osl/unx/salinit.cxx::sal_detail_initialize updates this:
bool sal_use_syslog;
#else
-enum { sal_use_syslog = false };
+bool const sal_use_syslog = false;
#endif
// Avoid the use of other sal code in this file as much as possible, so that
diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index fec3664..b618c68 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -22,19 +22,19 @@ rtl_uString *osl_backtraceAsString()
OUStringBuffer aBuf;
HANDLE hProcess = GetCurrentProcess();
- SymInitialize( hProcess, NULL, true );
+ SymInitialize( hProcess, nullptr, true );
void * aStack[ 512 ];
- sal_uInt32 nFrames = CaptureStackBackTrace( 0, 512, aStack, NULL );
+ sal_uInt32 nFrames = CaptureStackBackTrace( 0, 512, aStack, nullptr );
SYMBOL_INFO * pSymbol;
- pSymbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 1024 * sizeof( char ), 1 );
+ pSymbol = static_cast<SYMBOL_INFO *>(calloc( sizeof( SYMBOL_INFO ) + 1024 * sizeof( char ), 1 ));
pSymbol->MaxNameLen = 1024 - 1;
pSymbol->SizeOfStruct = sizeof( SYMBOL_INFO );
for( sal_uInt32 i = 0; i < nFrames; i++ )
{
- SymFromAddr( hProcess, ( DWORD64 )aStack[ i ], 0, pSymbol );
+ SymFromAddr( hProcess, reinterpret_cast<DWORD64>(aStack[ i ]), nullptr, pSymbol );
aBuf.append( (sal_Int32)(nFrames - i - 1) );
aBuf.append( ": " );
aBuf.appendAscii( pSymbol->Name );
diff --git a/sal/osl/w32/conditn.c b/sal/osl/w32/conditn.c
index 9947929..6f90e50 100644
--- a/sal/osl/w32/conditn.c
+++ b/sal/osl/w32/conditn.c
@@ -35,10 +35,10 @@ oslCondition SAL_CALL osl_createCondition(void)
{
oslCondition Condition;
- Condition= (oslCondition)CreateEvent(0, /* no security */
+ Condition= (oslCondition)CreateEvent(NULL, /* no security */
sal_True, /* manual reset */
sal_False, /* initial state not signaled */
- 0); /* automatic name */
+ NULL); /* automatic name */
return Condition;
diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c
index 97536ce..54133b5 100644
--- a/sal/osl/w32/dllentry.c
+++ b/sal/osl/w32/dllentry.c
@@ -36,10 +36,11 @@
#include "rtllifecycle.h"
+#include <thread.h>
+
// externals
extern DWORD g_dwTLSTextEncodingIndex;
-extern void SAL_CALL _osl_callThreadKeyCallbackOnThreadDetach(void);
extern CRITICAL_SECTION g_ThreadKeyListCS;
extern oslMutex g_Mutex;
extern oslMutex g_CurrentDirectoryMutex;
@@ -69,8 +70,8 @@ _pRawDllMain()
*/
-static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved );
-BOOL (WINAPI *_pRawDllMain)(HINSTANCE, DWORD, LPVOID) = _RawDllMain;
+static BOOL WINAPI RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved );
+BOOL (WINAPI *_pRawDllMain)(HINSTANCE, DWORD, LPVOID) = RawDllMain;
#endif
@@ -139,7 +140,7 @@ __main (void)
static void do_startup( void )
{
#else
-static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
+static BOOL WINAPI RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
(void)hinstDLL; /* avoid warnings */
(void)lpvReserved; /* avoid warnings */
@@ -322,7 +323,7 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
break;
case DLL_THREAD_DETACH:
- _osl_callThreadKeyCallbackOnThreadDetach( );
+ osl_callThreadKeyCallbackOnThreadDetach( );
break;
}
diff --git a/sal/osl/w32/file-impl.hxx b/sal/osl/w32/file-impl.hxx
new file mode 100644
index 0000000..a34e433
--- /dev/null
+++ b/sal/osl/w32/file-impl.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_OSL_W32_FILE_IMPL_HXX
+#define INCLUDED_SAL_OSL_W32_FILE_IMPL_HXX
+
+#include <sal/config.h>
+
+#include <osl/file.h>
+#include <sal/types.h>
+
+#include <windows.h>
+
+extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(
+ HANDLE hFile, sal_uInt32 uFlags);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index cb12df6..73cb2f8 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -23,6 +23,7 @@
#include "osl/file.hxx"
+#include <file-impl.hxx>
#include "file_url.h"
#include "file_error.h"
@@ -119,7 +120,7 @@ struct FileHandle_Impl
sal_Sequence ** ppSequence,
sal_uInt64 * pBytesRead);
- oslFileError writeSequence_Impl (
+ static oslFileError writeSequence_Impl (
sal_Sequence ** ppSequence,
SIZE_T * pnOffset,
const void * pBuffer,
@@ -134,8 +135,8 @@ struct FileHandle_Impl
rtl_cache_type * m_cache;
SIZE_T m_bufsiz;
- Allocator (Allocator const &);
- Allocator & operator= (Allocator const &);
+ Allocator (Allocator const &) = delete;
+ Allocator & operator= (Allocator const &) = delete;
public:
static Allocator & get();
@@ -168,42 +169,45 @@ FileHandle_Impl::Allocator::get()
}
FileHandle_Impl::Allocator::Allocator()
- : m_cache (0),
+ : m_cache (nullptr),
m_bufsiz (0)
{
SIZE_T const pagesize = FileHandle_Impl::getpagesize();
m_cache = rtl_cache_create (
- "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0);
- if (0 != m_cache)
+ "osl_file_buffer_cache", pagesize, 0, nullptr, nullptr, nullptr,
+ nullptr, nullptr, 0);
+ if (nullptr != m_cache)
m_bufsiz = pagesize;
}
FileHandle_Impl::Allocator::~Allocator()
{
- rtl_cache_destroy(m_cache), m_cache = 0;
+ rtl_cache_destroy(m_cache);
+ m_cache = nullptr;
}
void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize)
{
- OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
- *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz;
+ OSL_PRECOND((nullptr != ppBuffer) && (nullptr != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
+ *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache));
+ *pnSize = m_bufsiz;
}
void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
{
- if (0 != pBuffer)
+ if (nullptr != pBuffer)
rtl_cache_free (m_cache, pBuffer);
}
FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex)
: m_mutex (pMutex)
{
- OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer.");
+ OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::Guard(): null pointer.");
::EnterCriticalSection (m_mutex);
}
FileHandle_Impl::Guard::~Guard()
{
- OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer.");
+ OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::~Guard(): null pointer.");
::LeaveCriticalSection (m_mutex);
}
@@ -216,17 +220,18 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
m_bufptr (-1),
m_buflen (0),
m_bufsiz (0),
- m_buffer (0)
+ m_buffer (nullptr)
{
::InitializeCriticalSection (&m_mutex);
Allocator::get().allocate (&m_buffer, &m_bufsiz);
- if (m_buffer != 0)
+ if (m_buffer != nullptr)
memset (m_buffer, 0, m_bufsiz);
}
FileHandle_Impl::~FileHandle_Impl()
{
- Allocator::get().deallocate (m_buffer), m_buffer = 0;
+ Allocator::get().deallocate (m_buffer);
+ m_buffer = nullptr;
::DeleteCriticalSection (&m_mutex);
}
@@ -267,7 +272,7 @@ sal_uInt64 FileHandle_Impl::getSize() const
oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize)
{
LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize);
- if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN))
+ if (!::SetFilePointerEx(m_hFile, nDstPos, nullptr, FILE_BEGIN))
return oslTranslateFileError( GetLastError() );
if (!::SetEndOfFile(m_hFile))
@@ -275,7 +280,7 @@ oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize)
m_size = uSize;
nDstPos.QuadPart = m_offset;
- if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN))
+ if (!::SetFilePointerEx(m_hFile, nDstPos, nullptr, FILE_BEGIN))
return oslTranslateFileError( GetLastError() );
return osl_File_E_None;
@@ -298,13 +303,13 @@ oslFileError FileHandle_Impl::readAt (
if (nOffset != m_offset)
{
LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset;
- if (!::SetFilePointerEx(m_hFile, liOffset, 0, FILE_BEGIN))
+ if (!::SetFilePointerEx(m_hFile, liOffset, nullptr, FILE_BEGIN))
return oslTranslateFileError( GetLastError() );
m_offset = nOffset;
}
DWORD dwDone = 0;
- if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0))
+ if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, nullptr))
return oslTranslateFileError( GetLastError() );
m_offset += dwDone;
@@ -329,13 +334,13 @@ oslFileError FileHandle_Impl::writeAt (
if (nOffset != m_offset)
{
LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset;
- if (!::SetFilePointerEx (m_hFile, liOffset, 0, FILE_BEGIN))
+ if (!::SetFilePointerEx (m_hFile, liOffset, nullptr, FILE_BEGIN))
return oslTranslateFileError( GetLastError() );
m_offset = nOffset;
}
DWORD dwDone = 0;
- if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0))
+ if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, nullptr))
return oslTranslateFileError( GetLastError() );
m_offset += dwDone;
@@ -360,12 +365,12 @@ oslFileError FileHandle_Impl::readFileAt (
{
// not seekable (pipe)
DWORD dwDone = 0;
- if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0))
+ if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, nullptr))
return oslTranslateFileError( GetLastError() );
*pBytesRead = dwDone;
return osl_File_E_None;
}
- else if (0 == m_buffer)
+ else if (nullptr == m_buffer)
{
// not buffered
return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
@@ -384,7 +389,8 @@ oslFileError FileHandle_Impl::readFileAt (
oslFileError result = syncFile();
if (result != osl_File_E_None)
return result;
- m_bufptr = -1, m_buflen = 0;
+ m_bufptr = -1;
+ m_buflen = 0;
if (nBytesRequested >= m_bufsiz)
{
@@ -394,7 +400,8 @@ oslFileError FileHandle_Impl::readFileAt (
if (result != osl_File_E_None)
return result;
- nBytesRequested -= sal::static_int_cast< DWORD >(uDone), *pBytesRead += uDone;
+ nBytesRequested -= sal::static_int_cast< DWORD >(uDone);
+ *pBytesRead += uDone;
return osl_File_E_None;
}
@@ -403,7 +410,8 @@ oslFileError FileHandle_Impl::readFileAt (
result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
+ m_bufptr = bufptr;
+ m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
if (bufpos >= m_buflen)
{
@@ -413,7 +421,9 @@ oslFileError FileHandle_Impl::readFileAt (
SIZE_T const bytes = std::min(m_buflen - bufpos, (SIZE_T) nBytesRequested);
memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes);
- nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes;
+ nBytesRequested -= bytes;
+ *pBytesRead += bytes;
+ nOffset += bytes;
}
return osl_File_E_None;
}
@@ -434,12 +444,12 @@ oslFileError FileHandle_Impl::writeFileAt (
{
// not seekable (pipe)
DWORD dwDone = 0;
- if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0))
+ if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, nullptr))
return oslTranslateFileError( GetLastError() );
*pBytesWritten = dwDone;
return osl_File_E_None;
}
- else if (0 == m_buffer)
+ else if (nullptr == m_buffer)
{
// not buffered
return writeAt(nOffset, pBuffer, nBytesToWrite, pBytesWritten);
@@ -457,7 +467,8 @@ oslFileError FileHandle_Impl::writeFileAt (
oslFileError result = syncFile();
if (result != osl_File_E_None)
return result;
- m_bufptr = -1, m_buflen = 0;
+ m_bufptr = -1;
+ m_buflen = 0;
if (nBytesToWrite >= m_bufsiz)
{
@@ -469,7 +480,8 @@ oslFileError FileHandle_Impl::writeFileAt (
if (uDone != nBytesToWrite)
return osl_File_E_IO;
- nBytesToWrite -= sal::static_int_cast< DWORD >(uDone), *pBytesWritten += uDone;
+ nBytesToWrite -= sal::static_int_cast< DWORD >(uDone);
+ *pBytesWritten += uDone;
return osl_File_E_None;
}
@@ -478,12 +490,15 @@ oslFileError FileHandle_Impl::writeFileAt (
result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
+ m_bufptr = bufptr;
+ m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
SIZE_T const bytes = std::min(m_bufsiz - bufpos, (SIZE_T) nBytesToWrite);
memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes);
- nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes;
+ nBytesToWrite -= bytes;
+ *pBytesWritten += bytes;
+ nOffset += bytes;
m_buflen = std::max(m_buflen, bufpos + bytes);
m_state |= STATE_MODIFIED;
@@ -513,7 +528,8 @@ oslFileError FileHandle_Impl::readLineAt (
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
+ m_bufptr = bufptr;
+ m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
static int const LINE_STATE_BEGIN = 0;
@@ -535,7 +551,8 @@ oslFileError FileHandle_Impl::readLineAt (
ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos);
if (result != osl_File_E_None)
return result;
- *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
+ *pBytesRead += curpos - bufpos;
+ nOffset += curpos - bufpos;
}
bufptr = nOffset / m_bufsiz * m_bufsiz;
@@ -546,10 +563,12 @@ oslFileError FileHandle_Impl::readLineAt (
result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
+ m_bufptr = bufptr;
+ m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
- bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos;
+ bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr);
+ curpos = bufpos;
if (bufpos >= m_buflen)
break;
}
@@ -585,20 +604,22 @@ oslFileError FileHandle_Impl::readLineAt (
if (state != LINE_STATE_BEGIN)
{
/* store (and eat) the newline char */
- m_buffer[curpos] = 0x0A, curpos++;
+ m_buffer[curpos] = 0x0A;
+ curpos++;
/* flush buffer to sequence */
result = writeSequence_Impl (
ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1);
if (result != osl_File_E_None)
return result;
- *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
+ *pBytesRead += curpos - bufpos;
+ nOffset += curpos - bufpos;
}
break;
}
}
- result = writeSequence_Impl (ppSequence, &dstpos, 0, 0);
+ result = writeSequence_Impl (ppSequence, &dstpos, nullptr, 0);
if (result != osl_File_E_None)
return result;
if (0 < dstpos)
@@ -625,12 +646,13 @@ oslFileError FileHandle_Impl::writeSequence_Impl (
/* resize sequence */
rtl_byte_sequence_realloc(ppSequence, nElements);
}
- if (*ppSequence != 0)
+ if (*ppSequence != nullptr)
{
/* fill sequence */
- memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes;
+ memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes);
+ *pnOffset += nBytes;
}
- return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM;
+ return (*ppSequence != nullptr) ? osl_File_E_None : osl_File_E_NOMEM;
}
oslFileError FileHandle_Impl::syncFile()
@@ -657,14 +679,14 @@ SAL_CALL osl_createFileHandleFromOSHandle (
sal_uInt32 uFlags)
{
if ( !IsValidHandle(hFile) )
- return 0; // EINVAL
+ return nullptr; // EINVAL
FileHandle_Impl * pImpl = new FileHandle_Impl(hFile);
- if (pImpl == 0)
+ if (pImpl == nullptr)
{
// cleanup and fail
(void) ::CloseHandle(hFile);
- return 0; // ENOMEM
+ return nullptr; // ENOMEM
}
/* check for regular file */
@@ -688,7 +710,7 @@ SAL_CALL osl_createFileHandleFromOSHandle (
!((uFlags & osl_File_OpenFlag_Read) || (uFlags & osl_File_OpenFlag_Write)),
"sal.osl",
"osl_createFileHandleFromOSHandle(): missing read/write access flags");
- return (oslFileHandle)pImpl;
+ return static_cast<oslFileHandle>(pImpl);
}
oslFileError
@@ -697,8 +719,8 @@ SAL_CALL osl_openFile(
oslFileHandle * pHandle,
sal_uInt32 uFlags )
{
- rtl_uString * strSysPath = 0;
- oslFileError result = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ rtl_uString * strSysPath = nullptr;
+ oslFileError result = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if (result != osl_File_E_None)
return result;
@@ -719,7 +741,7 @@ SAL_CALL osl_openFile(
HANDLE hFile = CreateFileW(
rtl_uString_getStr( strSysPath ),
- dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL );
+ dwAccess, dwShare, nullptr, dwCreation, dwAttributes, nullptr );
// @@@ ERROR HANDLING @@@
if ( !IsValidHandle( hFile ) )
@@ -735,7 +757,7 @@ oslFileError
SAL_CALL osl_syncFile(oslFileHandle Handle)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
@@ -754,7 +776,7 @@ oslFileError
SAL_CALL osl_closeFile(oslFileHandle Handle)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
::EnterCriticalSection (&(pImpl->m_mutex));
@@ -799,16 +821,16 @@ SAL_CALL osl_mapFile(
};
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppAddr))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == ppAddr))
return osl_File_E_INVAL;
- *ppAddr = 0;
+ *ppAddr = nullptr;
static SIZE_T const nLimit = std::numeric_limits< SIZE_T >::max();
if (uLength > nLimit)
return osl_File_E_OVERFLOW;
SIZE_T const nLength = sal::static_int_cast< SIZE_T >(uLength);
- FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) );
+ FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, nullptr, SEC_COMMIT | PAGE_READONLY, 0, 0, nullptr) );
if (!IsValidHandle(aMap.m_handle))
return oslTranslateFileError( GetLastError() );
@@ -816,7 +838,7 @@ SAL_CALL osl_mapFile(
DWORD const dwOffsetLo = sal::static_int_cast<DWORD>(uOffset & 0xFFFFFFFF);
*ppAddr = ::MapViewOfFile( aMap.m_handle, FILE_MAP_READ, dwOffsetHi, dwOffsetLo, nLength );
- if (0 == *ppAddr)
+ if (nullptr == *ppAddr)
return oslTranslateFileError( GetLastError() );
if (uFlags & osl_File_MapFlag_RandomAccess)
@@ -830,7 +852,7 @@ SAL_CALL osl_mapFile(
* Pagein, touching first byte of each memory page.
* Note: volatile disables optimizing the loop away.
*/
- BYTE * pData (reinterpret_cast<BYTE*>(*ppAddr));
+ BYTE * pData (static_cast<BYTE*>(*ppAddr));
SIZE_T nSize (nLength);
volatile BYTE c = 0;
@@ -851,7 +873,7 @@ SAL_CALL osl_mapFile(
oslFileError
SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */)
{
- if (0 == pAddr)
+ if (nullptr == pAddr)
return osl_File_E_INVAL;
if (!::UnmapViewOfFile (pAddr))
@@ -872,7 +894,7 @@ SAL_CALL osl_readLine(
sal_Sequence ** ppSequence)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppSequence))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == ppSequence))
return osl_File_E_INVAL;
sal_uInt64 uBytesRead = 0;
@@ -893,7 +915,7 @@ SAL_CALL osl_readFile(
sal_uInt64 * pBytesRead)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesRead))
return osl_File_E_INVAL;
// read at current filepos; filepos += *pBytesRead;
@@ -914,7 +936,7 @@ SAL_CALL osl_writeFile(
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesWritten))
return osl_File_E_INVAL;
// write at current filepos; filepos += *pBytesWritten;
@@ -936,7 +958,7 @@ SAL_CALL osl_readFileAt(
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesRead))
return osl_File_E_INVAL;
if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
return osl_File_E_SPIPE;
@@ -961,7 +983,7 @@ SAL_CALL osl_writeFileAt(
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pBuffer) || (nullptr == pBytesWritten))
return osl_File_E_INVAL;
if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
return osl_File_E_SPIPE;
@@ -981,7 +1003,7 @@ SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pIsEOF))
return osl_File_E_INVAL;
FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
@@ -993,7 +1015,7 @@ oslFileError
SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pPos))
return osl_File_E_INVAL;
FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
@@ -1005,7 +1027,7 @@ oslFileError
SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
static sal_Int64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
@@ -1049,7 +1071,7 @@ SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile) || (nullptr == pSize))
return osl_File_E_INVAL;
FileHandle_Impl::Guard lock (&(pImpl->m_mutex));
@@ -1062,7 +1084,7 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize)
{
FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
+ if ((nullptr == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE))
return osl_File_E_BADF;
@@ -1075,7 +1097,8 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize)
oslFileError result = pImpl->syncFile();
if (result != osl_File_E_None)
return result;
- pImpl->m_bufptr = -1, pImpl->m_buflen = 0;
+ pImpl->m_bufptr = -1;
+ pImpl->m_buflen = 0;
return pImpl->setSize (uSize);
}
@@ -1084,8 +1107,8 @@ SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize)
oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
{
- rtl_uString *strSysPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ rtl_uString *strSysPath = nullptr;
+ oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if ( osl_File_E_None == error )
{
@@ -1101,11 +1124,11 @@ oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath )
{
- rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr;
+ oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
+ error = osl_getSystemPathFromFileURL_( strDestPath, &strSysDestPath, false );
if ( osl_File_E_None == error )
{
@@ -1128,11 +1151,11 @@ oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPa
oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath )
{
- rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ rtl_uString *strSysPath = nullptr, *strSysDestPath = nullptr;
+ oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
+ error = osl_getSystemPathFromFileURL_( strDestPath, &strSysDestPath, false );
if ( osl_File_E_None == error )
{
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 33ef6e3..a2fbfc1 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -24,6 +24,7 @@
#include "osl/file.h"
#include "file_url.h"
+#include <filetime.h>
#include <sal/macros.h>
#include "file_error.h"
@@ -44,7 +45,7 @@ static const wchar_t UNC_PREFIX[] = L"\\\\";
static const wchar_t BACKSLASH = '\\';
static const wchar_t SLASH = '/';
-extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime)
+BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime)
{
SYSTEMTIME BaseSysTime;
FILETIME BaseFileTime;
@@ -68,15 +69,15 @@ extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime
__int64 timeValue;
__int64 localTime = cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100;
- *(__int64 *)&FTime=localTime;
- fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime));
+ osl::detail::setFiletime(FTime, localTime);
+ fSuccess = 0 <= (timeValue= osl::detail::getFiletime(BaseFileTime) + osl::detail::getFiletime(FTime));
if (fSuccess)
- *(__int64 *)pFTime=timeValue;
+ osl::detail::setFiletime(*pFTime, timeValue);
}
return fSuccess;
}
-extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal)
+BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal)
{
SYSTEMTIME BaseSysTime;
FILETIME BaseFileTime;
@@ -95,7 +96,7 @@ extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal
{
__int64 Value;
- fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime));
+ fSuccess = 0 <= (Value = osl::detail::getFiletime(*cpFTime) - osl::detail::getFiletime(BaseFileTime));
if ( fSuccess )
{
@@ -112,7 +113,7 @@ namespace /* private */
struct Component
{
Component() :
- begin_(0), end_(0)
+ begin_(nullptr), end_(nullptr)
{}
bool isPresent() const
@@ -199,7 +200,7 @@ oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handl
{
if ( Handle )
{
- rtl_uString_acquire( (rtl_uString *)Handle );
+ rtl_uString_acquire( static_cast<rtl_uString *>(Handle) );
return osl_File_E_None;
}
else
@@ -210,7 +211,7 @@ oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handl
{
if ( Handle )
{
- rtl_uString_release( (rtl_uString *)Handle );
+ rtl_uString_release( static_cast<rtl_uString *>(Handle) );
return osl_File_E_None;
}
else
@@ -221,7 +222,7 @@ oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle
{
if ( Handle && pstrPath )
{
- rtl_uString_assign( pstrPath, (rtl_uString *)Handle );
+ rtl_uString_assign( pstrPath, static_cast<rtl_uString *>(Handle) );
return osl_File_E_None;
}
else
@@ -269,7 +270,7 @@ typedef struct tagDRIVEENUM
static HANDLE WINAPI OpenLogicalDrivesEnum()
{
- LPDRIVEENUM pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) );
+ LPDRIVEENUM pEnum = static_cast<LPDRIVEENUM>(HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) ));
if ( pEnum )
{
DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(WCHAR), pEnum->cBuffer );
@@ -285,13 +286,13 @@ static HANDLE WINAPI OpenLogicalDrivesEnum()
pEnum = nullptr;
}
}
- return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE;
+ return pEnum ? static_cast<HANDLE>(pEnum) : INVALID_HANDLE_VALUE;
}
static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer)
{
BOOL fSuccess = FALSE;
- LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
+ LPDRIVEENUM pEnum = static_cast<LPDRIVEENUM>(hEnum);
if ( pEnum )
{
@@ -315,7 +316,7 @@ static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPWSTR lpBuffer)
static BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum)
{
BOOL fSuccess = FALSE;
- LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
+ LPDRIVEENUM pEnum = static_cast<LPDRIVEENUM>(hEnum);
if ( pEnum )
{
@@ -343,7 +344,7 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
sal_uInt32 nLen = rtl_uString_getLength( pPath );
if ( nLen )
{
- const WCHAR* pSuffix = 0;
+ const WCHAR* pSuffix = nullptr;
sal_uInt32 nSuffLen = 0;
if ( pPath->buffer[nLen - 1] != L'\\' )
@@ -357,12 +358,12 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
nSuffLen = 3;
}
- WCHAR* szFileMask = reinterpret_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) );
+ WCHAR* szFileMask = static_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) );
_tcscpy( szFileMask, rtl_uString_getStr( pPath ) );
_tcscat( szFileMask, pSuffix );
- pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
+ pDirectory = static_cast<LPDIRECTORY>(HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)));
pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData);
if (!IsValidHandle(pDirectory->hFind))
@@ -377,13 +378,13 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
}
}
- return (HANDLE)pDirectory;
+ return static_cast<HANDLE>(pDirectory);
}
BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData)
{
BOOL fSuccess = FALSE;
- LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+ LPDIRECTORY pDirectory = static_cast<LPDIRECTORY>(hDirectory);
if ( pDirectory )
{
@@ -418,7 +419,7 @@ BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData)
static BOOL WINAPI CloseDirectory(HANDLE hDirectory)
{
BOOL fSuccess = FALSE;
- LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+ LPDIRECTORY pDirectory = static_cast<LPDIRECTORY>(hDirectory);
if (pDirectory)
{
@@ -444,12 +445,12 @@ static oslFileError osl_openLocalRoot(
*pDirectory = nullptr;
- error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False );
+ error = osl_getSystemPathFromFileURL_( strDirectoryPath, &strSysPath, false );
if ( osl_File_E_None == error )
{
Directory_Impl *pDirImpl;
- pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl)));
+ pDirImpl = static_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl)));
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strSysPath );
@@ -461,8 +462,8 @@ static oslFileError osl_openLocalRoot(
sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
{
- rtl_uString* pCurDir = 0;
- rtl_uString* pBackSlash = 0;
+ rtl_uString* pCurDir = nullptr;
+ rtl_uString* pBackSlash = nullptr;
rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
rtl_uString_newFromAscii( &pBackSlash, "\\" );
@@ -479,7 +480,7 @@ static oslFileError osl_openLocalRoot(
*/
if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE )
{
- *pDirectory = (oslDirectory)pDirImpl;
+ *pDirectory = static_cast<oslDirectory>(pDirImpl);
error = osl_File_E_None;
}
else
@@ -489,11 +490,11 @@ static oslFileError osl_openLocalRoot(
if ( pDirImpl->m_pDirectoryPath )
{
rtl_uString_release( pDirImpl->m_pDirectoryPath );
- pDirImpl->m_pDirectoryPath = 0;
+ pDirImpl->m_pDirectoryPath = nullptr;
}
rtl_freeMemory(pDirImpl);
- pDirImpl = 0;
+ pDirImpl = nullptr;
}
error = oslTranslateFileError( GetLastError() );
@@ -513,7 +514,7 @@ static oslFileError SAL_CALL osl_openFileDirectory(
return osl_File_E_INVAL;
*pDirectory = nullptr;
- Directory_Impl *pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strDirectoryPath );
@@ -525,8 +526,8 @@ static oslFileError SAL_CALL osl_openFileDirectory(
sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
{
- rtl_uString* pCurDir = 0;
- rtl_uString* pBackSlash = 0;
+ rtl_uString* pCurDir = nullptr;
+ rtl_uString* pBackSlash = nullptr;
rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
rtl_uString_newFromAscii( &pBackSlash, "\\" );
@@ -545,13 +546,14 @@ static oslFileError SAL_CALL osl_openFileDirectory(
if ( pDirImpl->m_pDirectoryPath )
{
rtl_uString_release( pDirImpl->m_pDirectoryPath );
- pDirImpl->m_pDirectoryPath = 0;
+ pDirImpl->m_pDirectoryPath = nullptr;
}
- rtl_freeMemory(pDirImpl), pDirImpl = 0;
+ rtl_freeMemory(pDirImpl);
+ pDirImpl = nullptr;
}
- *pDirectory = (oslDirectory)(pDirImpl);
+ *pDirectory = static_cast<oslDirectory>(pDirImpl);
return error;
}
@@ -577,11 +579,11 @@ static oslFileError SAL_CALL osl_openNetworkServer(
{
Directory_Impl *pDirImpl;
- pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
+ pDirImpl = static_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
pDirImpl->uType = DIRECTORYTYPE_NETROOT;
pDirImpl->hDirectory = hEnum;
- *pDirectory = (oslDirectory)pDirImpl;
+ *pDirectory = static_cast<oslDirectory>(pDirImpl);
}
return oslTranslateFileError( dwError );
}
@@ -602,7 +604,7 @@ static DWORD create_dir_with_callback(
if (aDirectoryCreationCallbackFunc)
{
rtl::OUString url;
- _osl_getFileURLFromSystemPath(dir_path, &(url.pData));
+ osl_getFileURLFromSystemPath_(dir_path, &(url.pData));
aDirectoryCreationCallbackFunc(pData, url.pData);
}
return ERROR_SUCCESS;
@@ -668,7 +670,7 @@ oslFileError SAL_CALL osl_createDirectoryPath(
rtl::OUString sys_path;
oslFileError osl_error =
- _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False);
+ osl_getSystemPathFromFileURL_(aDirectoryUrl, &sys_path.pData, false);
if (osl_error != osl_File_E_None)
return osl_error;
@@ -691,7 +693,7 @@ oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32)
{
rtl_uString *strSysPath = nullptr;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if ( osl_File_E_None == error )
{
@@ -726,7 +728,7 @@ oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32)
oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath)
{
rtl_uString *strSysPath = nullptr;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ oslFileError error = osl_getSystemPathFromFileURL_( strPath, &strSysPath, false );
if ( osl_File_E_None == error )
{
@@ -751,7 +753,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect
rtl_uString *strSysDirectoryPath = nullptr;
DWORD dwPathType;
- error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False );
+ error = osl_getSystemPathFromFileURL_( strDirectoryPath, &strSysDirectoryPath, false );
if ( osl_File_E_None != error )
return error;
@@ -773,10 +775,10 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirect
static oslFileError SAL_CALL osl_getNextNetResource(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ )
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl *>(Directory);
DirectoryItem_Impl *pItemImpl = nullptr;
BYTE buffer[16384];
- LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer;
+ LPNETRESOURCEW lpNetResource = reinterpret_cast<LPNETRESOURCEW>(buffer);
DWORD dwError, dwCount, dwBufSize;
if ( !pItem )
@@ -795,13 +797,13 @@ static oslFileError SAL_CALL osl_getNextNetResource(
case NO_ERROR:
case ERROR_MORE_DATA:
{
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ pItemImpl = static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
if ( !pItemImpl )
return osl_File_E_NOMEM;
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
pItemImpl->uType = DIRECTORYITEM_DRIVE;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName );
@@ -818,7 +820,7 @@ static oslFileError SAL_CALL osl_getNextNetResource(
static oslFileError SAL_CALL osl_getNextDrive(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/ )
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl *>(Directory);
DirectoryItem_Impl *pItemImpl = nullptr;
BOOL fSuccess;
@@ -829,13 +831,13 @@ static oslFileError SAL_CALL osl_getNextDrive(
if ( !pDirImpl )
return osl_File_E_INVAL;
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ pItemImpl = static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
if ( !pItemImpl )
return osl_File_E_NOMEM;
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
pItemImpl->uType = DIRECTORYITEM_DRIVE;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString );
if ( fSuccess )
@@ -848,7 +850,7 @@ static oslFileError SAL_CALL osl_getNextDrive(
if ( pItemImpl->m_pFullPath )
{
rtl_uString_release( pItemImpl->m_pFullPath );
- pItemImpl->m_pFullPath = 0;
+ pItemImpl->m_pFullPath = nullptr;
}
rtl_freeMemory( pItemImpl );
@@ -859,7 +861,7 @@ static oslFileError SAL_CALL osl_getNextDrive(
static oslFileError SAL_CALL osl_getNextFileItem(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 /*uHint*/)
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl *>(Directory);
DirectoryItem_Impl *pItemImpl = nullptr;
BOOL fFound;
@@ -870,7 +872,7 @@ static oslFileError SAL_CALL osl_getNextFileItem(
if ( !pDirImpl )
return osl_File_E_INVAL;
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ pItemImpl = static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
if ( !pItemImpl )
return osl_File_E_NOMEM;
@@ -882,13 +884,13 @@ static oslFileError SAL_CALL osl_getNextFileItem(
pItemImpl->uType = DIRECTORYITEM_FILE;
pItemImpl->nRefCount = 1;
- rtl_uString* pTmpFileName = 0;
+ rtl_uString* pTmpFileName = nullptr;
rtl_uString_newFromStr( &pTmpFileName, pItemImpl->FindData.cFileName );
rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName );
rtl_uString_release( pTmpFileName );
pItemImpl->bFullPathNormalized = FALSE;
- *pItem = (oslDirectoryItem)pItemImpl;
+ *pItem = static_cast<oslDirectoryItem>(pItemImpl);
return osl_File_E_None;
}
else
@@ -896,7 +898,7 @@ static oslFileError SAL_CALL osl_getNextFileItem(
if ( pItemImpl->m_pFullPath )
{
rtl_uString_release( pItemImpl->m_pFullPath );
- pItemImpl->m_pFullPath = 0;
+ pItemImpl->m_pFullPath = nullptr;
}
rtl_freeMemory( pItemImpl );
@@ -907,7 +909,7 @@ static oslFileError SAL_CALL osl_getNextFileItem(
oslFileError SAL_CALL osl_getNextDirectoryItem(
oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl *>(Directory);
/* Assume failure */
@@ -933,7 +935,7 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(
oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ Directory_Impl *pDirImpl = static_cast<Directory_Impl *>(Directory);
oslFileError eError = osl_File_E_INVAL;
if ( pDirImpl )
@@ -960,7 +962,7 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
if ( pDirImpl->m_pDirectoryPath )
{
rtl_uString_release( pDirImpl->m_pDirectoryPath );
- pDirImpl->m_pDirectoryPath = 0;
+ pDirImpl->m_pDirectoryPath = nullptr;
}
rtl_freeMemory(pDirImpl);
@@ -969,14 +971,14 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
}
/* Different types of paths */
-typedef enum _PATHTYPE
+enum PATHTYPE
{
PATHTYPE_SYNTAXERROR = 0,
PATHTYPE_NETROOT,
PATHTYPE_NETSERVER,
PATHTYPE_VOLUME,
PATHTYPE_FILE
-} PATHTYPE;
+};
oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem)
{
@@ -992,7 +994,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
*pItem = nullptr;
- error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False );
+ error = osl_getSystemPathFromFileURL_( strFilePath, &strSysFilePath, false );
if ( osl_File_E_None != error )
return error;
@@ -1011,7 +1013,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
case PATHTYPE_NETSERVER:
{
DirectoryItem_Impl* pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
if ( !pItemImpl )
error = osl_File_E_NOMEM;
@@ -1021,7 +1023,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
pItemImpl->uType = DIRECTORYITEM_SERVER;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath );
// Assign a title anyway
@@ -1042,7 +1044,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
case PATHTYPE_VOLUME:
{
DirectoryItem_Impl* pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
if ( !pItemImpl )
error = osl_File_E_NOMEM;
@@ -1052,7 +1054,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
pItemImpl->uType = DIRECTORYITEM_DRIVE;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
_tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer );
pItemImpl->cDriveString[0] = rtl::toAsciiUpperCase( pItemImpl->cDriveString[0] );
@@ -1079,10 +1081,10 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
if ( hFind != INVALID_HANDLE_VALUE )
{
DirectoryItem_Impl *pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ static_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) );
CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) );
rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath );
@@ -1108,7 +1110,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item )
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ DirectoryItem_Impl *pItemImpl = static_cast<DirectoryItem_Impl *>(Item);
if ( !pItemImpl )
return osl_File_E_INVAL;
@@ -1119,7 +1121,7 @@ oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item )
oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ DirectoryItem_Impl *pItemImpl = static_cast<DirectoryItem_Impl *>(Item);
if ( !pItemImpl )
return osl_File_E_INVAL;
@@ -1129,7 +1131,7 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
if ( pItemImpl->m_pFullPath )
{
rtl_uString_release( pItemImpl->m_pFullPath );
- pItemImpl->m_pFullPath = 0;
+ pItemImpl->m_pFullPath = nullptr;
}
rtl_freeMemory( pItemImpl );
@@ -1141,18 +1143,18 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
sal_Bool
SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
{
- DirectoryItem_Impl *pA = (DirectoryItem_Impl *) a;
- DirectoryItem_Impl *pB = (DirectoryItem_Impl *) b;
+ DirectoryItem_Impl *pA = static_cast<DirectoryItem_Impl *>(a);
+ DirectoryItem_Impl *pB = static_cast<DirectoryItem_Impl *>(b);
if (a == b)
- return sal_True;
+ return true;
/* same name => same item, unless renaming / moving madness has occurred */
if (pA->m_pFullPath == pB->m_pFullPath)
- return sal_True;
+ return true;
// FIXME: as/when/if this is used in anger on Windows we could
// do better here.
- return sal_False;
+ return false;
}
// volume / file info handling functions
@@ -1313,8 +1315,8 @@ static void get_volume_space_information(
{
BOOL ret = GetDiskFreeSpaceEx(
path.getStr(),
- (PULARGE_INTEGER)&(pInfo->uFreeSpace),
- (PULARGE_INTEGER)&(pInfo->uTotalSpace),
+ reinterpret_cast<PULARGE_INTEGER>(&pInfo->uFreeSpace),
+ reinterpret_cast<PULARGE_INTEGER>(&pInfo->uTotalSpace),
nullptr);
if (ret)
@@ -1422,7 +1424,7 @@ oslFileError SAL_CALL osl_getVolumeInformation(
return osl_File_E_INVAL;
rtl::OUString system_path;
- oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False);
+ oslFileError error = osl_getSystemPathFromFileURL_(ustrURL, &system_path.pData, false);
if (osl_File_E_None != error)
return error;
@@ -1440,7 +1442,7 @@ oslFileError SAL_CALL osl_getVolumeInformation(
if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
{
- error = osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle);
+ error = osl_getFileURLFromSystemPath(volume_root.pData, reinterpret_cast<rtl_uString**>(&pInfo->pDeviceHandle));
if (error != osl_File_E_None)
return error;
pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
@@ -1452,7 +1454,7 @@ oslFileError SAL_CALL osl_getVolumeInformation(
static oslFileError SAL_CALL osl_getDriveInfo(
oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ DirectoryItem_Impl *pItemImpl = static_cast<DirectoryItem_Impl *>(Item);
WCHAR cDrive[3] = TEXT("A:");
WCHAR cRoot[4] = TEXT("A:\\");
@@ -1550,7 +1552,7 @@ static oslFileError SAL_CALL osl_getDriveInfo(
static oslFileError SAL_CALL osl_getServerInfo(
oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask )
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ DirectoryItem_Impl *pItemImpl = static_cast<DirectoryItem_Impl *>(Item);
if ( !pItemImpl )
return osl_File_E_INVAL;
@@ -1581,7 +1583,7 @@ oslFileError SAL_CALL osl_getFileStatus(
oslFileStatus *pStatus,
sal_uInt32 uFieldMask )
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ DirectoryItem_Impl *pItemImpl = static_cast<DirectoryItem_Impl *>(Item);
if ( !pItemImpl )
return osl_File_E_INVAL;
@@ -1673,7 +1675,7 @@ oslFileError SAL_CALL osl_getFileStatus(
sal_uInt32 nNewLen = GetCaseCorrectPathName( rtl_uString_getStr( pItemImpl->m_pFullPath ),
::osl::mingw_reinterpret_cast<LPWSTR>( aBuffer ),
aBuffer.getBufSizeInSymbols(),
- sal_True );
+ true );
if ( nNewLen )
{
@@ -1703,7 +1705,7 @@ oslFileError SAL_CALL osl_setFileAttributes(
BOOL fSuccess;
// Converts the normalized path into a systempath
- error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False );
+ error = osl_getSystemPathFromFileURL_( ustrFileURL, &ustrSysPath, false );
if ( osl_File_E_None != error )
return error;
@@ -1750,7 +1752,7 @@ oslFileError SAL_CALL osl_setFileTime(
HANDLE hFile;
BOOL fSuccess;
- error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False);
+ error=osl_getSystemPathFromFileURL_(filePath, &sysPath, false);
if (error==osl_File_E_INVAL)
return error;
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 5009082..ca41be6 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -43,7 +43,7 @@
// FileURL functions
extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */
-oslMutex g_CurrentDirectoryMutex = 0;
+oslMutex g_CurrentDirectoryMutex = nullptr;
static BOOL IsValidFilePathComponent(
LPCWSTR lpComponent, LPCWSTR *lppComponentEnd, DWORD dwFlags)
@@ -483,19 +483,19 @@ DWORD GetCaseCorrectPathName(
return 0;
}
-static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
+static bool osl_decodeURL_( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
{
sal_Char *pBuffer;
const sal_Char *pSrcEnd;
const sal_Char *pSrc;
sal_Char *pDest;
sal_Int32 nSrcLen;
- sal_Bool bValidEncoded = sal_True; /* Assume success */
+ bool bValidEncoded = true; /* Assume success */
/* The resulting decoded string length is shorter or equal to the source length */
nSrcLen = rtl_string_getLength(strUTF8);
- pBuffer = reinterpret_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1));
+ pBuffer = static_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1));
pDest = pBuffer;
pSrc = rtl_string_getStr(strUTF8);
@@ -521,7 +521,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR
/* The chars are path delimiters and must not be encoded */
if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar )
- bValidEncoded = sal_False;
+ bValidEncoded = false;
else
*pDest++ = aChar;
}
@@ -529,7 +529,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR
case '\0':
case '#':
case '?':
- bValidEncoded = sal_False;
+ bValidEncoded = false;
break;
default:
*pDest++ = *pSrc++;
@@ -542,7 +542,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR
if ( bValidEncoded )
{
rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
- OSL_ASSERT(*pstrDecodedURL != 0);
+ OSL_ASSERT(*pstrDecodedURL != nullptr);
}
rtl_freeMemory( pBuffer );
@@ -550,7 +550,7 @@ static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedUR
return bValidEncoded;
}
-static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
+static void osl_encodeURL_( rtl_uString *strURL, rtl_String **pstrEncodedURL )
{
/* Encode non ascii characters within the URL */
@@ -563,7 +563,7 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
- pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) );
+ pszEncodedURL = static_cast<sal_Char*>(rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) ));
pURLDest = pszEncodedURL;
pURLScan = rtl_string_getStr( strUTF8 );
@@ -619,13 +619,13 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
rtl_freeMemory( pszEncodedURL );
}
-oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
+oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
{
rtl_String *strUTF8 = nullptr;
rtl_uString *strDecodedURL = nullptr;
rtl_uString *strTempPath = nullptr;
sal_uInt32 nDecodedLen;
- sal_Bool bValidEncoded;
+ bool bValidEncoded;
oslFileError nError = osl_File_E_INVAL; /* Assume failure */
/* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from
@@ -641,7 +641,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
, "sal.osl"
,"osl_getSystemPathFromFileURL: \"" << rtl::OUString(strURL) << "\" is not encoded !!!");
- bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL );
+ bValidEncoded = osl_decodeURL_( strUTF8, &strDecodedURL );
/* Release the encoded UTF8 string */
rtl_string_release( strUTF8 );
@@ -687,7 +687,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
sal_uInt32 nNewLen = GetCaseCorrectPathName( pDecodedURL + nSkip,
::osl::mingw_reinterpret_cast<LPWSTR>(aBuf),
aBuf.getBufSizeInSymbols(),
- sal_False );
+ 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 )
@@ -755,7 +755,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
return nError;
}
-oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL )
+oslFileError osl_getFileURLFromSystemPath_( rtl_uString* strPath, rtl_uString** pstrURL )
{
oslFileError nError = osl_File_E_INVAL; /* Assume failure */
rtl_uString *strTempURL = nullptr;
@@ -843,11 +843,11 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString**
rtl_String *strEncodedURL = nullptr;
/* Encode the URL */
- _osl_encodeURL( strTempURL, &strEncodedURL );
+ osl_encodeURL_( strTempURL, &strEncodedURL );
/* Provide URL via unicode string */
rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS );
- OSL_ASSERT(*pstrURL != 0);
+ OSL_ASSERT(*pstrURL != nullptr);
rtl_string_release( strEncodedURL );
}
@@ -863,13 +863,13 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString**
oslFileError SAL_CALL osl_getFileURLFromSystemPath(
rtl_uString* ustrPath, rtl_uString** pustrURL )
{
- return _osl_getFileURLFromSystemPath( ustrPath, pustrURL );
+ return osl_getFileURLFromSystemPath_( ustrPath, pustrURL );
}
oslFileError SAL_CALL osl_getSystemPathFromFileURL(
rtl_uString *ustrURL, rtl_uString **pustrPath)
{
- return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True );
+ return osl_getSystemPathFromFileURL_( ustrURL, pustrPath, true );
}
oslFileError SAL_CALL osl_searchFileURL(
@@ -882,12 +882,12 @@ oslFileError SAL_CALL osl_searchFileURL(
oslFileError error;
/* First try to interpret the file name as an URL even a relative one */
- error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True );
+ error = osl_getSystemPathFromFileURL_( ustrFileName, &ustrUNCPath, true );
/* So far we either have an UNC path or something invalid
Now create a system path */
if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True );
+ error = osl_getSystemPathFromFileURL_( ustrUNCPath, &ustrSysPath, true );
if ( osl_File_E_None == error )
{
@@ -911,8 +911,8 @@ oslFileError SAL_CALL osl_searchFileURL(
/* +1 is not necessary if we follow MSDN documentation but for robustness we do so */
nBufferLength = dwResult + 1;
lpBuffer = lpBuffer ?
- reinterpret_cast<LPWSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(WCHAR))) :
- reinterpret_cast<LPWSTR>(rtl_allocateMemory(nBufferLength * sizeof(WCHAR)));
+ static_cast<LPWSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(WCHAR))) :
+ static_cast<LPWSTR>(rtl_allocateMemory(nBufferLength * sizeof(WCHAR)));
dwResult = SearchPath( lpszSearchPath, lpszSearchFile, nullptr, nBufferLength, lpBuffer, &lpszFilePart );
} while ( dwResult && dwResult >= nBufferLength );
@@ -962,14 +962,14 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
if ( ustrBaseURL && ustrBaseURL->length )
{
- eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False );
+ eError = osl_getSystemPathFromFileURL_( ustrBaseURL, &ustrBaseSysPath, false );
OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" );
- eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True );
+ eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, &ustrRelSysPath, true );
}
else
{
- eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False );
+ eError = osl_getSystemPathFromFileURL_( ustrRelativeURL, &ustrRelSysPath, false );
OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" );
}
diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h
index 0f51b4c..ccb99fc 100644
--- a/sal/osl/w32/file_url.h
+++ b/sal/osl/w32/file_url.h
@@ -70,13 +70,13 @@ DWORD GetCaseCorrectPathName (
BOOL bCheckExistence
);
-oslFileError _osl_getSystemPathFromFileURL (
+oslFileError osl_getSystemPathFromFileURL_ (
rtl_uString * strURL,
rtl_uString ** pustrPath,
sal_Bool bAllowRelative
);
-oslFileError _osl_getFileURLFromSystemPath (
+oslFileError osl_getFileURLFromSystemPath_ (
rtl_uString * strPath,
rtl_uString ** pstrURL
);
diff --git a/sal/osl/w32/filetime.h b/sal/osl/w32/filetime.h
new file mode 100644
index 0000000..130dd8e
--- /dev/null
+++ b/sal/osl/w32/filetime.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_OSL_W32_FILETIME_H
+#define INCLUDED_SAL_OSL_W32_FILETIME_H
+
+#include <sal/config.h>
+
+#include <windows.h>
+
+#include <osl/time.h>
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+BOOL TimeValueToFileTime(TimeValue const * cpTimeVal, FILETIME * pFTime);
+
+BOOL FileTimeToTimeValue(FILETIME const * cpFTime, TimeValue * pTimeVal);
+
+#if defined __cplusplus
+}
+#endif
+
+#if defined __cplusplus
+
+namespace osl { namespace detail {
+
+inline __int64 getFiletime(FILETIME const & ft) {
+ return (DWORD64(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
+}
+
+inline void setFiletime(FILETIME & ft, __int64 value) {
+ ft.dwHighDateTime = value >> 32;
+ ft.dwLowDateTime = value & 0xFFFFFFFF;
+}
+
+} }
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index e88810b..f6bba2e 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -43,11 +43,11 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM
#if OSL_DEBUG_LEVEL < 2
UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
#endif
- rtl_uString* Module = NULL;
- oslModule ret = 0;
+ rtl_uString* Module = nullptr;
+ oslModule ret = nullptr;
oslFileError nError;
- SAL_INFO( "sal.osl", "osl_loadModule: " << OUString((sal_Unicode*)strModuleName->buffer, wcslen(strModuleName->buffer)) );
+ SAL_INFO( "sal.osl", "osl_loadModule: " << OUString(strModuleName->buffer, wcslen(strModuleName->buffer)) );
OSL_ASSERT(strModuleName);
nError = osl_getSystemPathFromFileURL(strModuleName, &Module);
@@ -57,8 +57,8 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM
h = LoadLibraryW(reinterpret_cast<LPCWSTR>(Module->buffer));
- if (h == NULL)
- h = LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), NULL,
+ if (h == nullptr)
+ h = LoadLibraryExW(reinterpret_cast<LPCWSTR>(Module->buffer), nullptr,
LOAD_WITH_ALTERED_SEARCH_PATH);
//In case of long path names (\\?\c:\...) try to shorten the filename.
@@ -66,7 +66,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM
//In case the path is to long, the function will fail. However, the error
//code can be different. For example, it returned ERROR_FILENAME_EXCED_RANGE
//on Windows XP and ERROR_INSUFFICIENT_BUFFER on Windows 7 (64bit)
- if (h == NULL && Module->length > 260)
+ if (h == nullptr && Module->length > 260)
{
std::vector<WCHAR> vec(Module->length + 1);
DWORD len = GetShortPathNameW(reinterpret_cast<LPCWSTR>(Module->buffer),
@@ -75,13 +75,13 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM
{
h = LoadLibraryW(reinterpret_cast<LPWSTR>(&vec[0]));
- if (h == NULL)
- h = LoadLibraryExW(reinterpret_cast<LPWSTR>(&vec[0]), NULL,
+ if (h == nullptr)
+ h = LoadLibraryExW(reinterpret_cast<LPWSTR>(&vec[0]), nullptr,
LOAD_WITH_ALTERED_SEARCH_PATH);
}
}
- ret = (oslModule) h;
+ ret = static_cast<oslModule>(h);
rtl_uString_release(Module);
#if OSL_DEBUG_LEVEL < 2
SetErrorMode(errorMode);
@@ -99,17 +99,17 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR
HMODULE h;
UINT errorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
- oslModule ret = 0;
+ oslModule ret = nullptr;
SAL_INFO( "sal.osl", "osl_loadModule: " << pModuleName );
OSL_ASSERT(pModuleName);
h = LoadLibrary(pModuleName);
- if (h == NULL)
- h = LoadLibraryEx(pModuleName, NULL,
+ if (h == nullptr)
+ h = LoadLibraryEx(pModuleName, nullptr,
LOAD_WITH_ALTERED_SEARCH_PATH);
- ret = (oslModule) h;
+ ret = static_cast<oslModule>(h);
SetErrorMode(errorMode);
return ret;
@@ -128,15 +128,15 @@ oslModule osl_loadModuleRelativeAscii(
sal_Bool SAL_CALL
osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult)
{
- LPCWSTR pName = pModuleName ? reinterpret_cast<LPCWSTR>(pModuleName->buffer) : NULL;
+ LPCWSTR pName = pModuleName ? reinterpret_cast<LPCWSTR>(pModuleName->buffer) : nullptr;
HMODULE h = GetModuleHandleW(pName);
if( h )
{
- *pResult = (oslModule) h;
- return sal_True;
+ *pResult = static_cast<oslModule>(h);
+ return true;
}
- return sal_False;
+ return false;
}
/*****************************************************************************/
@@ -144,7 +144,7 @@ osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult)
/*****************************************************************************/
void SAL_CALL osl_unloadModule(oslModule Module)
{
- FreeLibrary((HMODULE)Module);
+ FreeLibrary(static_cast<HMODULE>(Module));
}
/*****************************************************************************/
@@ -160,7 +160,7 @@ void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName)
#pragma warning(push)
#pragma warning(disable:4054)
#endif
- return (void*)(osl_getFunctionSymbol(Module, strSymbolName));
+ return reinterpret_cast<void*>(osl_getFunctionSymbol(Module, strSymbolName));
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -171,7 +171,7 @@ void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName)
/*****************************************************************************/
oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *strSymbolName )
{
- rtl_String *symbolName = NULL;
+ rtl_String *symbolName = nullptr;
oslGenericFunction address;
OSL_ASSERT(Module);
@@ -197,10 +197,10 @@ oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString
oslGenericFunction SAL_CALL
osl_getAsciiFunctionSymbol( oslModule Module, const sal_Char *pSymbol )
{
- oslGenericFunction fncAddr = NULL;
+ oslGenericFunction fncAddr = nullptr;
if( pSymbol )
- fncAddr=(oslGenericFunction)GetProcAddress((HMODULE) Module, pSymbol);
+ fncAddr=reinterpret_cast<oslGenericFunction>(GetProcAddress(static_cast<HMODULE>(Module), pSymbol));
return fncAddr;
}
@@ -256,9 +256,9 @@ typedef BOOL (WINAPI *SymGetModuleInfo_PROC)(
BTW: We are using ANSI function because not all version of IMAGEHLP.DLL contain Unicode support
*/
-static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **pustrURL )
+static bool SAL_CALL osl_addressGetModuleURL_NT4_( void *pv, rtl_uString **pustrURL )
{
- sal_Bool bSuccess = sal_False; /* Assume failure */
+ bool bSuccess = false; /* Assume failure */
/* IMAGEHELP.DLL has a bug that it recursivly scans subdirectories of
the root when calling SymInitialize(), so we preferr DBGHELP.DLL
@@ -275,23 +275,23 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p
SymInitialize_PROC lpfnSymInitialize;
SymCleanup_PROC lpfnSymCleanup;
- lpfnSymInitialize = (SymInitialize_PROC)GetProcAddress( hModImageHelp, "SymInitialize" );
- lpfnSymCleanup = (SymCleanup_PROC)GetProcAddress( hModImageHelp, "SymCleanup" );
- lpfnSymGetModuleInfo = (SymGetModuleInfo_PROC)GetProcAddress( hModImageHelp, "SymGetModuleInfo" );
+ lpfnSymInitialize = reinterpret_cast<SymInitialize_PROC>(GetProcAddress( hModImageHelp, "SymInitialize" ));
+ lpfnSymCleanup = reinterpret_cast<SymCleanup_PROC>(GetProcAddress( hModImageHelp, "SymCleanup" ));
+ lpfnSymGetModuleInfo = reinterpret_cast<SymGetModuleInfo_PROC>(GetProcAddress( hModImageHelp, "SymGetModuleInfo" ));
if ( lpfnSymInitialize && lpfnSymCleanup && lpfnSymGetModuleInfo )
{
IMAGEHLP_MODULE ModuleInfo;
::osl::LongPathBuffer< sal_Char > aModuleFileName( MAX_LONG_PATH );
- LPSTR lpSearchPath = NULL;
+ LPSTR lpSearchPath = nullptr;
- if ( GetModuleFileNameA( NULL, aModuleFileName, aModuleFileName.getBufSizeInSymbols() ) )
+ if ( GetModuleFileNameA( nullptr, aModuleFileName, aModuleFileName.getBufSizeInSymbols() ) )
{
char *pLastBkSlash = strrchr( aModuleFileName, '\\' );
if (
pLastBkSlash &&
- pLastBkSlash > (sal_Char*)aModuleFileName
+ pLastBkSlash > static_cast<sal_Char*>(aModuleFileName)
&& *(pLastBkSlash - 1) != ':'
&& *(pLastBkSlash - 1) != '\\'
)
@@ -306,7 +306,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p
ZeroMemory( &ModuleInfo, sizeof(ModuleInfo) );
ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
- bSuccess = (sal_Bool)(!!lpfnSymGetModuleInfo( GetCurrentProcess(), (DWORD_PTR)pv, &ModuleInfo ));
+ bSuccess = !!lpfnSymGetModuleInfo( GetCurrentProcess(), reinterpret_cast<DWORD_PTR>(pv), &ModuleInfo );
if ( bSuccess )
{
@@ -315,17 +315,17 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p
BaseOfImage to a HMODULE (on NT it's the same) and use GetModuleFileName to retrieve the full
path of the loaded image */
- if ( ModuleInfo.LoadedImageName[0] || GetModuleFileNameA( (HMODULE)ModuleInfo.BaseOfImage, ModuleInfo.LoadedImageName, sizeof(ModuleInfo.LoadedImageName) ) )
+ if ( ModuleInfo.LoadedImageName[0] || GetModuleFileNameA( reinterpret_cast<HMODULE>(ModuleInfo.BaseOfImage), ModuleInfo.LoadedImageName, sizeof(ModuleInfo.LoadedImageName) ) )
{
- rtl_uString *ustrSysPath = NULL;
+ rtl_uString *ustrSysPath = nullptr;
rtl_string2UString( &ustrSysPath, ModuleInfo.LoadedImageName, strlen(ModuleInfo.LoadedImageName), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
- OSL_ASSERT(ustrSysPath != NULL);
+ OSL_ASSERT(ustrSysPath != nullptr);
osl_getFileURLFromSystemPath( ustrSysPath, pustrURL );
rtl_uString_release( ustrSysPath );
}
else
- bSuccess = sal_False;
+ bSuccess = false;
}
lpfnSymCleanup( GetCurrentProcess() );
@@ -337,11 +337,11 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p
return bSuccess;
}
-typedef struct _MODULEINFO {
+typedef struct MODULEINFO {
LPVOID lpBaseOfDll;
DWORD SizeOfImage;
LPVOID EntryPoint;
-} MODULEINFO, *LPMODULEINFO;
+} *LPMODULEINFO;
typedef BOOL (WINAPI *EnumProcessModules_PROC)(
HANDLE hProcess, // handle to the process
@@ -359,30 +359,30 @@ typedef BOOL (WINAPI *GetModuleInformation_PROC)(
/* This version can fail because PSAPI.DLL is not always part of NT 4 despite MSDN Library 6.0a say so */
-static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pustrURL )
+static bool SAL_CALL osl_addressGetModuleURL_NT_( void *pv, rtl_uString **pustrURL )
{
- sal_Bool bSuccess = sal_False; /* Assume failure */
- static HMODULE hModPsapi = NULL;
+ bool bSuccess = false; /* Assume failure */
+ static HMODULE hModPsapi = nullptr;
if ( !hModPsapi )
hModPsapi = LoadLibrary( "PSAPI.DLL" );
if ( hModPsapi )
{
- EnumProcessModules_PROC lpfnEnumProcessModules = (EnumProcessModules_PROC)GetProcAddress( hModPsapi, "EnumProcessModules" );
- GetModuleInformation_PROC lpfnGetModuleInformation = (GetModuleInformation_PROC)GetProcAddress( hModPsapi, "GetModuleInformation" );
+ EnumProcessModules_PROC lpfnEnumProcessModules = reinterpret_cast<EnumProcessModules_PROC>(GetProcAddress( hModPsapi, "EnumProcessModules" ));
+ GetModuleInformation_PROC lpfnGetModuleInformation = reinterpret_cast<GetModuleInformation_PROC>(GetProcAddress( hModPsapi, "GetModuleInformation" ));
if ( lpfnEnumProcessModules && lpfnGetModuleInformation )
{
DWORD cbNeeded = 0;
- HMODULE *lpModules = NULL;
+ HMODULE *lpModules = nullptr;
DWORD nModules = 0;
UINT iModule = 0;
MODULEINFO modinfo;
- lpfnEnumProcessModules( GetCurrentProcess(), NULL, 0, &cbNeeded );
+ lpfnEnumProcessModules( GetCurrentProcess(), nullptr, 0, &cbNeeded );
- lpModules = (HMODULE *)_alloca( cbNeeded );
+ lpModules = static_cast<HMODULE *>(_alloca( cbNeeded ));
lpfnEnumProcessModules( GetCurrentProcess(), lpModules, cbNeeded, &cbNeeded );
nModules = cbNeeded / sizeof(HMODULE);
@@ -391,10 +391,10 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu
{
lpfnGetModuleInformation( GetCurrentProcess(), lpModules[iModule], &modinfo, sizeof(modinfo) );
- if ( (BYTE *)pv >= (BYTE *)modinfo.lpBaseOfDll && (BYTE *)pv < (BYTE *)modinfo.lpBaseOfDll + modinfo.SizeOfImage )
+ if ( static_cast<BYTE *>(pv) >= static_cast<BYTE *>(modinfo.lpBaseOfDll) && static_cast<BYTE *>(pv) < static_cast<BYTE *>(modinfo.lpBaseOfDll) + modinfo.SizeOfImage )
{
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
- rtl_uString *ustrSysPath = NULL;
+ rtl_uString *ustrSysPath = nullptr;
GetModuleFileNameW( lpModules[iModule], ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), aBuffer.getBufSizeInSymbols() );
@@ -402,7 +402,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu
osl_getFileURLFromSystemPath( ustrSysPath, pustrURL );
rtl_uString_release( ustrSysPath );
- bSuccess = sal_True;
+ bSuccess = true;
}
}
}
@@ -419,7 +419,7 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu
sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL )
{
/* Use ..._NT first because ..._NT4 is much slower */
- return _osl_addressGetModuleURL_NT( pv, pustrURL ) || _osl_addressGetModuleURL_NT4( pv, pustrURL );
+ return osl_addressGetModuleURL_NT_( pv, pustrURL ) || osl_addressGetModuleURL_NT4_( pv, pustrURL );
}
/*****************************************************************************/
@@ -435,7 +435,7 @@ sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction addr,
#pragma warning(push)
#pragma warning(disable:4054)
#endif
- return osl_getModuleURLFromAddress((void*)addr, ppLibraryUrl);
+ return osl_getModuleURLFromAddress(reinterpret_cast<void*>(addr), ppLibraryUrl);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
diff --git a/sal/osl/w32/nlsupport.c b/sal/osl/w32/nlsupport.c
index 3448988..afee159 100644
--- a/sal/osl/w32/nlsupport.c
+++ b/sal/osl/w32/nlsupport.c
@@ -27,6 +27,8 @@
#endif
#include <wchar.h>
+#include <nlsupport.h>
+
#include <osl/mutex.h>
#include <osl/nlsupport.h>
#include <osl/diagnose.h>
@@ -209,7 +211,7 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
* imp_getProcessLocale
*****************************************************************************/
-void _imp_getProcessLocale( rtl_Locale ** ppLocale )
+void imp_getProcessLocale( rtl_Locale ** ppLocale )
{
WCHAR langCode[ELP_LANGUAGE_FIELD_LENGTH];
WCHAR ctryCode[ELP_COUNTRY_FIELD_LENGTH];
diff --git a/sal/osl/w32/nlsupport.h b/sal/osl/w32/nlsupport.h
new file mode 100644
index 0000000..e42d391
--- /dev/null
+++ b/sal/osl/w32/nlsupport.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_OSL_W32_NLSUPPORT_H
+#define INCLUDED_SAL_OSL_W32_NLSUPPORT_H
+
+#include <sal/config.h>
+
+#include <rtl/locale.h>
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+void imp_getProcessLocale(rtl_Locale ** ppLocale);
+
+#if defined __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sal/osl/w32/path_helper.cxx b/sal/osl/w32/path_helper.cxx
index 2887860..a79373d 100644
--- a/sal/osl/w32/path_helper.cxx
+++ b/sal/osl/w32/path_helper.cxx
@@ -41,7 +41,7 @@ const rtl::OUString SLASH ("/");
void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString** ppustrPath)
{
- OSL_PRECOND(ppustrPath && (NULL != *ppustrPath), \
+ OSL_PRECOND(ppustrPath && (nullptr != *ppustrPath), \
"osl_systemPathEnsureSeparator: Invalid parameter");
rtl::OUString path(*ppustrPath);
diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx
index ee77791..a31cd37 100644
--- a/sal/osl/w32/path_helper.hxx
+++ b/sal/osl/w32/path_helper.hxx
@@ -75,7 +75,7 @@ class LongPathBuffer
public:
explicit LongPathBuffer( sal_uInt32 nCharNum )
- : m_pBuffer( reinterpret_cast<T*>( rtl_allocateMemory( nCharNum * sizeof( T ) ) ) )
+ : m_pBuffer( static_cast<T*>( rtl_allocateMemory( nCharNum * sizeof( T ) ) ) )
, m_nCharNum( nCharNum )
{
OSL_ENSURE( m_pBuffer, "Can not allocate the buffer!" );
@@ -85,7 +85,7 @@ public:
{
if ( m_pBuffer )
rtl_freeMemory( m_pBuffer );
- m_pBuffer = 0;
+ m_pBuffer = nullptr;
}
sal_uInt32 getBufSizeInSymbols()
diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c
index bbcdf09..7693a25 100644
--- a/sal/osl/w32/pipe.c
+++ b/sal/osl/w32/pipe.c
@@ -64,7 +64,7 @@ struct oslPipeImpl {
/* osl_create/destroy-PipeImpl */
/*****************************************************************************/
-oslPipe __osl_createPipeImpl(void)
+oslPipe osl_createPipeImpl(void)
{
oslPipe pPipe;
@@ -83,7 +83,7 @@ oslPipe __osl_createPipeImpl(void)
return pPipe;
}
-void __osl_destroyPipeImpl(oslPipe pPipe)
+void osl_destroyPipeImpl(oslPipe pPipe)
{
if (pPipe != NULL)
{
@@ -160,7 +160,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
rtl_uString_newConcat(&name, temp, strPipeName);
/* alloc memory */
- pPipe= __osl_createPipeImpl();
+ pPipe= osl_createPipeImpl();
osl_atomic_increment(&(pPipe->m_Reference));
/* build system pipe name */
@@ -245,7 +245,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
}
/* if we reach here something went wrong */
- __osl_destroyPipeImpl(pPipe);
+ osl_destroyPipeImpl(pPipe);
return NULL;
}
@@ -259,7 +259,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
{
// OSL_ASSERT( pPipe );
- if( 0 == pPipe )
+ if( NULL == pPipe )
return;
if( 0 == osl_atomic_decrement( &(pPipe->m_Reference) ) )
@@ -267,7 +267,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
if( ! pPipe->m_bClosed )
osl_closePipe( pPipe );
- __osl_destroyPipeImpl( pPipe );
+ osl_destroyPipeImpl( pPipe );
}
}
@@ -331,16 +331,16 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
break; // Everything's fine !!!
default:
// Something went wrong
- return 0;
+ return NULL;
}
}
break;
default: // All other error say that somethings going wrong.
- return 0;
+ return NULL;
}
}
- pAcceptedPipe = __osl_createPipeImpl();
+ pAcceptedPipe = osl_createPipeImpl();
OSL_ASSERT(pAcceptedPipe);
osl_atomic_increment(&(pAcceptedPipe->m_Reference));
diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index 8c3e116..1b08a24 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -37,6 +37,8 @@
#include <osl/thread.h>
#include <sal/log.hxx>
+#include <filetime.h>
+#include <nlsupport.h>
#include "procimpl.h"
#include "sockimpl.h"
#include "file_url.h"
@@ -50,10 +52,10 @@
oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process)
{
- if (Process == NULL)
+ if (Process == nullptr)
return osl_Process_E_Unknown;
- if (TerminateProcess(((oslProcessImpl*)Process)->m_hProcess, 0))
+ if (TerminateProcess(static_cast<oslProcessImpl*>(Process)->m_hProcess, 0))
return osl_Process_E_None;
return osl_Process_E_Unknown;
@@ -69,12 +71,12 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
if (hProcess)
{
- pProcImpl = reinterpret_cast< oslProcessImpl*>( rtl_allocateMemory(sizeof(oslProcessImpl)) );
+ pProcImpl = static_cast< oslProcessImpl*>( rtl_allocateMemory(sizeof(oslProcessImpl)) );
pProcImpl->m_hProcess = hProcess;
pProcImpl->m_IdProcess = Ident;
}
else
- pProcImpl = NULL;
+ pProcImpl = nullptr;
return pProcImpl;
}
@@ -83,11 +85,11 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
void SAL_CALL osl_freeProcessHandle(oslProcess Process)
{
- if (Process != NULL)
+ if (Process != nullptr)
{
- CloseHandle(((oslProcessImpl*)Process)->m_hProcess);
+ CloseHandle(static_cast<oslProcessImpl*>(Process)->m_hProcess);
- rtl_freeMemory((oslProcessImpl*)Process);
+ rtl_freeMemory(Process);
}
}
@@ -99,15 +101,15 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
HANDLE hProcess;
DWORD IdProcess;
- if (Process == NULL)
+ if (Process == nullptr)
{
hProcess = GetCurrentProcess();
IdProcess = GetCurrentProcessId();
}
else
{
- hProcess = ((oslProcessImpl*)Process)->m_hProcess;
- IdProcess = ((oslProcessImpl*)Process)->m_IdProcess;
+ hProcess = static_cast<oslProcessImpl*>(Process)->m_hProcess;
+ IdProcess = static_cast<oslProcessImpl*>(Process)->m_IdProcess;
}
if (! pInfo || (pInfo->Size != sizeof(oslProcessInfo)))
@@ -129,7 +131,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
if (Fields & osl_Process_HEAPUSAGE)
{
- void* lpAddress=0;
+ void* lpAddress=nullptr;
MEMORY_BASIC_INFORMATION Info;
pInfo->HeapUsage = 0;
@@ -142,9 +144,9 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
if ((Info.State == MEM_COMMIT) && (Info.Type == MEM_PRIVATE))
pInfo->HeapUsage += Info.RegionSize;
- lpAddress = (LPBYTE)lpAddress + Info.RegionSize;
+ lpAddress = static_cast<LPBYTE>(lpAddress) + Info.RegionSize;
}
- while ((uintptr_t)lpAddress <= (uintptr_t)0x7FFFFFFF); // 2GB address space
+ while (reinterpret_cast<uintptr_t>(lpAddress) <= (uintptr_t)0x7FFFFFFF); // 2GB address space
pInfo->Fields |= osl_Process_HEAPUSAGE;
}
@@ -158,11 +160,11 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
{
__int64 Value;
- Value = *((__int64 *)&UserTime);
+ Value = osl::detail::getFiletime(UserTime);
pInfo->UserTime.Seconds = (unsigned long) (Value / 10000000L);
pInfo->UserTime.Nanosec = (unsigned long)((Value % 10000000L) * 100);
- Value = *((__int64 *)&KernelTime);
+ Value = osl::detail::getFiletime(KernelTime);
pInfo->SystemTime.Seconds = (unsigned long) (Value / 10000000L);
pInfo->SystemTime.Nanosec = (unsigned long)((Value % 10000000L) * 100);
@@ -177,7 +179,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
oslProcessError SAL_CALL osl_joinProcess(oslProcess Process)
{
- return osl_joinProcessWithTimeout(Process, NULL);
+ return osl_joinProcessWithTimeout(Process, nullptr);
}
/***************************************************************************/
@@ -188,13 +190,13 @@ oslProcessError SAL_CALL osl_joinProcessWithTimeout(oslProcess Process, const Ti
oslProcessError osl_error = osl_Process_E_None;
DWORD ret;
- if (NULL == Process)
+ if (nullptr == Process)
return osl_Process_E_Unknown;
if (pTimeout)
timeout = pTimeout->Seconds * 1000 + pTimeout->Nanosec / 1000000L;
- ret = WaitForSingleObject(((oslProcessImpl*)Process)->m_hProcess, timeout);
+ ret = WaitForSingleObject(static_cast<oslProcessImpl*>(Process)->m_hProcess, timeout);
if (WAIT_FAILED == ret)
osl_error = osl_Process_E_Unknown;
@@ -213,9 +215,9 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL)
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
DWORD buflen = 0;
- if ((buflen = GetModuleFileNameW (0, ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), aBuffer.getBufSizeInSymbols())) > 0)
+ if ((buflen = GetModuleFileNameW (nullptr, ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), aBuffer.getBufSizeInSymbols())) > 0)
{
- rtl_uString * pAbsPath = 0;
+ rtl_uString * pAbsPath = nullptr;
rtl_uString_newFromStr_WithLength (&(pAbsPath), aBuffer, buflen);
if (pAbsPath)
{
@@ -247,7 +249,7 @@ struct CommandArgs_Impl
static struct CommandArgs_Impl g_command_args =
{
0,
- 0
+ nullptr
};
#ifdef _MSC_VER
@@ -257,8 +259,8 @@ static struct CommandArgs_Impl g_command_args =
static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **)
{
rtl_uString ** ppArgs =
- (rtl_uString**)rtl_allocateZeroMemory (argc * sizeof(rtl_uString*));
- if (ppArgs != 0)
+ static_cast<rtl_uString**>(rtl_allocateZeroMemory (argc * sizeof(rtl_uString*)));
+ if (ppArgs != nullptr)
{
int i;
int nArgs;
@@ -269,14 +271,14 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **)
/* Convert to unicode */
rtl_uString_newFromStr( &(ppArgs[i]), reinterpret_cast<const sal_Unicode*>(wargv[i]) );
}
- if (ppArgs[0] != 0)
+ if (ppArgs[0] != nullptr)
{
/* Ensure absolute path */
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
DWORD dwResult = 0;
dwResult = SearchPath (
- 0, reinterpret_cast<LPCWSTR>(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), 0);
+ nullptr, reinterpret_cast<LPCWSTR>(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), ::osl::mingw_reinterpret_cast<LPWSTR>(aBuffer), nullptr);
if ((0 < dwResult) && (dwResult < aBuffer.getBufSizeInSymbols()))
{
/* Replace argv[0] with its absolute path */
@@ -284,12 +286,12 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **)
&(ppArgs[0]), aBuffer, dwResult);
}
}
- if (ppArgs[0] != 0)
+ if (ppArgs[0] != nullptr)
{
/* Convert to FileURL, see @ osl_getExecutableFile() */
- rtl_uString * pResult = 0;
+ rtl_uString * pResult = nullptr;
osl_getFileURLFromSystemPath (ppArgs[0], &pResult);
- if (pResult != 0)
+ if (pResult != nullptr)
{
rtl_uString_assign (&(ppArgs[0]), pResult);
rtl_uString_release (pResult);
@@ -369,7 +371,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
if (g_command_args.m_nCount == 0)
{
rtl_uString** ppArgs = osl_createCommandArgs_Impl (argc, argv);
- if (ppArgs != 0)
+ if (ppArgs != nullptr)
{
g_command_args.m_nCount = argc;
g_command_args.m_ppArgs = ppArgs;
@@ -418,7 +420,7 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar)
// delete the variable from the current process environment
// by setting SetEnvironmentVariable's second parameter to NULL
LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
- if (SetEnvironmentVariableW(lpName, NULL))
+ if (SetEnvironmentVariableW(lpName, nullptr))
{
wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1];
wcscpy(buffer, lpName);
@@ -448,7 +450,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir
if ( dwLen && dwLen < aBuffer.getBufSizeInSymbols() )
{
oslFileError eError;
- rtl_uString *ustrTemp = NULL;
+ rtl_uString *ustrTemp = nullptr;
rtl_uString_newFromStr_WithLength( &ustrTemp, aBuffer, dwLen );
eError = osl_getFileURLFromSystemPath( ustrTemp, pustrWorkingDir );
@@ -468,9 +470,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir
* Process Locale.
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list