summaryrefslogtreecommitdiff
path: root/helpcompiler
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-10-03 12:44:07 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-10-03 16:30:36 +0200
commit532a4dcba6ec6fe1bd88f3c2db77f05868167886 (patch)
tree82857bab5b8914677e0d17a4b668dfcb97b0467e /helpcompiler
parent372d2d78906aac32ddaf7eaa3c2037ea3d5af1ae (diff)
Replace more reinterpret_cast with SAL_W/SAL_U
Change-Id: Ia632e4083222ad9e7f17c2ad0d0825f189c700cc Reviewed-on: https://gerrit.libreoffice.org/43071 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'helpcompiler')
-rw-r--r--helpcompiler/inc/HelpCompiler.hxx4
-rw-r--r--helpcompiler/source/HelpLinker.cxx52
2 files changed, 18 insertions, 38 deletions
diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx
index 12f6ada7b824..8d8a920da696 100644
--- a/helpcompiler/inc/HelpCompiler.hxx
+++ b/helpcompiler/inc/HelpCompiler.hxx
@@ -88,11 +88,11 @@ namespace fs
return std::string(tmp.getStr());
}
#ifdef _WIN32
- wchar_t const * native_file_string_w() const
+ std::wstring native_file_string_w() const
{
OUString ustrSystemPath;
osl::File::getSystemPathFromFileURL(data, ustrSystemPath);
- return reinterpret_cast<wchar_t const *>(ustrSystemPath.getStr());
+ return std::wstring(SAL_W(ustrSystemPath.getStr()));
}
#endif
std::string toUTF8() const
diff --git a/helpcompiler/source/HelpLinker.cxx b/helpcompiler/source/HelpLinker.cxx
index ae54fadb68a7..07303afe9e6a 100644
--- a/helpcompiler/source/HelpLinker.cxx
+++ b/helpcompiler/source/HelpLinker.cxx
@@ -38,6 +38,17 @@
#include <expat.h>
#include <memory>
+namespace {
+FILE* fopen_impl(const fs::path& rPath, const char* szMode)
+{
+#ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP
+ return _wfopen(rPath.native_file_string_w().c_str(), SAL_W(OUString::createFromAscii(szMode).getStr()));
+#else
+ return fopen(rPath.native_file_string().c_str(), szMode);
+#endif
+}
+}
+
IndexerPreProcessor::IndexerPreProcessor
( const fs::path& fsIndexBaseDir,
const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet )
@@ -87,13 +98,7 @@ void IndexerPreProcessor::processDocument
if( pResNodeCaption )
{
fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL;
-#ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP
- FILE* pFile_docURL = _wfopen(
- fsCaptionPureTextFile_docURL.native_file_string_w(), L"w" );
-#else
- FILE* pFile_docURL = fopen(
- fsCaptionPureTextFile_docURL.native_file_string().c_str(), "w" );
-#endif
+ FILE* pFile_docURL = fopen_impl( fsCaptionPureTextFile_docURL, "w" );
if( pFile_docURL )
{
fprintf( pFile_docURL, "%s\n", pResNodeCaption->content );
@@ -110,13 +115,7 @@ void IndexerPreProcessor::processDocument
if( pResNodeContent )
{
fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL;
-#ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP
- FILE* pFile_docURL = _wfopen(
- fsContentPureTextFile_docURL.native_file_string_w(), L"w" );
-#else
- FILE* pFile_docURL = fopen(
- fsContentPureTextFile_docURL.native_file_string().c_str(), "w" );
-#endif
+ FILE* pFile_docURL = fopen_impl( fsContentPureTextFile_docURL, "w" );
if( pFile_docURL )
{
fprintf( pFile_docURL, "%s\n", pResNodeContent->content );
@@ -186,11 +185,7 @@ public:
void dump_DBHelp( const fs::path& rFileName )
{
-#ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP
- FILE* pFile = _wfopen( rFileName.native_file_string_w(), L"wb" );
-#else
- FILE* pFile = fopen( rFileName.native_file_string().c_str(), "wb" );
-#endif
+ FILE* pFile = fopen_impl( rFileName, "wb" );
if( pFile == nullptr )
return;
@@ -296,25 +291,10 @@ void HelpLinker::link()
bUse_ = false;
fs::path helpTextFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".ht_" : ".ht")));
-#ifdef _WIN32
- //We need _wfopen to support long file paths on Windows XP
- FILE* pFileHelpText_DBHelp = _wfopen
- ( helpTextFileName_DBHelp.native_file_string_w(), L"wb" );
-#else
-
- FILE* pFileHelpText_DBHelp = fopen
- ( helpTextFileName_DBHelp.native_file_string().c_str(), "wb" );
-#endif
+ FILE* pFileHelpText_DBHelp = fopen_impl( helpTextFileName_DBHelp, "wb" );
fs::path dbBaseFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".db_" : ".db")));
-#ifdef _WIN32
- //We need _wfopen to support long file paths on Windows XP
- FILE* pFileDbBase_DBHelp = _wfopen
- ( dbBaseFileName_DBHelp.native_file_string_w(), L"wb" );
-#else
- FILE* pFileDbBase_DBHelp = fopen
- ( dbBaseFileName_DBHelp.native_file_string().c_str(), "wb" );
-#endif
+ FILE* pFileDbBase_DBHelp = fopen_impl( dbBaseFileName_DBHelp, "wb" );
fs::path keyWordFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".key_" : ".key")));