[Libreoffice-commits] .: l10ntools/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Tue Feb 28 07:29:20 PST 2012


 l10ntools/source/common.hxx   |   32 +++++++++++++++++++-------------
 l10ntools/source/xmlparse.cxx |    8 ++------
 2 files changed, 21 insertions(+), 19 deletions(-)

New commits:
commit 4aa17570a75097741f78b03ad9dff0688fbed513
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 28 16:28:55 2012 +0100

    Make sure osl_openFile is called with an absolute URL

diff --git a/l10ntools/source/common.hxx b/l10ntools/source/common.hxx
index fb11844..0129c6a 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 24dedf0..e646308 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)


More information about the Libreoffice-commits mailing list