diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-02-28 16:28:55 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-02-28 16:28:55 +0100 |
commit | 4aa17570a75097741f78b03ad9dff0688fbed513 (patch) | |
tree | 79b7c557e5e236b6d87100c71b68e3efdd4ee14d | |
parent | ef37bb6a02674cf676cadcd69445b4deadad9be6 (diff) |
Make sure osl_openFile is called with an absolute URL
-rw-r--r-- | l10ntools/source/common.hxx | 32 | ||||
-rw-r--r-- | l10ntools/source/xmlparse.cxx | 8 |
2 files changed, 21 insertions, 19 deletions
diff --git a/l10ntools/source/common.hxx b/l10ntools/source/common.hxx index fb11844e6b1b..0129c6a7c34e 100644 --- a/l10ntools/source/common.hxx +++ b/l10ntools/source/common.hxx @@ -47,12 +47,29 @@ namespace common { -inline rtl::OString pathnameToken(char const * pathname, char const * root) { +inline rtl::OUString pathnameToAbsoluteUrl(rtl::OUString const & pathname) { + rtl::OUString url; + if (osl::FileBase::getFileURLFromSystemPath(pathname, url) + != osl::FileBase::E_None) + { + std::cerr << "Error: Cannot convert input pathname to URL\n"; + std::exit(EXIT_FAILURE); + } rtl::OUString cwd; if (osl_getProcessWorkingDir(&cwd.pData) != osl_Process_E_None) { std::cerr << "Error: Cannot determine cwd\n"; std::exit(EXIT_FAILURE); } + if (osl::FileBase::getAbsoluteFileURL(cwd, url, url) + != osl::FileBase::E_None) + { + std::cerr << "Error: Cannot convert input URL to absolute URL\n"; + std::exit(EXIT_FAILURE); + } + return url; +} + +inline rtl::OString pathnameToken(char const * pathname, char const * root) { rtl::OUString full; if (!rtl_convertStringToUString( &full.pData, pathname, rtl_str_getLength(pathname), @@ -64,18 +81,7 @@ inline rtl::OString pathnameToken(char const * pathname, char const * root) { std::cerr << "Error: Cannot convert input pathname to UTF-16\n"; std::exit(EXIT_FAILURE); } - if (osl::FileBase::getFileURLFromSystemPath(full, full) - != osl::FileBase::E_None) - { - std::cerr << "Error: Cannot convert input pathname to URL\n"; - std::exit(EXIT_FAILURE); - } - if (osl::FileBase::getAbsoluteFileURL(cwd, full, full) - != osl::FileBase::E_None) - { - std::cerr << "Error: Cannot convert input URL to absolute URL\n"; - std::exit(EXIT_FAILURE); - } + full = pathnameToAbsoluteUrl(full); if (root == 0) { std::cerr << "Error: No project root argument\n"; std::exit(EXIT_FAILURE); diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx index 24dedf095832..e64630864d6d 100644 --- a/l10ntools/source/xmlparse.cxx +++ b/l10ntools/source/xmlparse.cxx @@ -33,6 +33,7 @@ #include <stdio.h> #include <sal/alloca.h> +#include "common.hxx" #include "xmlparse.hxx" #include <fstream> #include <iostream> @@ -1123,12 +1124,7 @@ XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFileName, XMLFile* pXML RTL_CONSTASCII_USTRINGPARAM("ERROR: Unable to open file ")); aErrorInformation.sMessage += rFileName; - rtl::OUString aFileURL; - if (osl::File::getFileURLFromSystemPath(rFileName, aFileURL) - != osl::File::E_None) - { - return 0; - } + rtl::OUString aFileURL(common::pathnameToAbsoluteUrl(rFileName)); oslFileHandle h; if (osl_openFile(aFileURL.pData, &h, osl_File_OpenFlag_Read) |