summaryrefslogtreecommitdiff
path: root/cpputools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-12-18 14:38:39 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-18 16:23:23 +0100
commita25bec0cb20671a8a8e2eacd61138773f4275875 (patch)
treece45b65dbfbe667f53e74027cf0b44a610119450 /cpputools
parent7b01977c7a50ab5b16d894a0760d61bf04970766 (diff)
Properly absolutize all registry arguments of uno executable
What was found to not work is something like "-ro services.rdb" referencing an XML-format services.rdb that itself contains relative uri attributes. The uno executable would not make an absolute file URL from "services.rdb" due to no leading ".", so trying to absolutize any relative uri attributes against the relative .rdb URL lead to MalformedUriExceptions. Change-Id: Ib41fc8e42b9848f5e77f44c86e1857a3d287d634
Diffstat (limited to 'cpputools')
-rw-r--r--cpputools/source/unoexe/unoexe.cxx52
1 files changed, 15 insertions, 37 deletions
diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx
index e6590a3fedfc..20256aee38fc 100644
--- a/cpputools/source/unoexe/unoexe.cxx
+++ b/cpputools/source/unoexe/unoexe.cxx
@@ -29,6 +29,7 @@
#include <rtl/process.h>
#include <rtl/string.h>
#include <rtl/strbuf.hxx>
+#include <rtl/uri.hxx>
#include <rtl/ustrbuf.hxx>
#include <uno/environment.h>
@@ -58,12 +59,6 @@
#include <osl/thread.h>
#include <osl/file.hxx>
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
-
using namespace std;
using namespace osl;
using namespace cppu;
@@ -83,42 +78,18 @@ using ::rtl::OUStringBuffer;
namespace unoexe
{
-static sal_Bool isFileUrl(const OUString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
-
static OUString convertToFileUrl(const OUString& fileName)
{
- if ( isFileUrl(fileName) )
- {
- return fileName;
+ OUString uWorkingDir;
+ if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) {
+ OSL_ASSERT(false);
}
-
- OUString uUrlFileName;
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
+ if (!uWorkingDir.isEmpty()
+ && uWorkingDir[uWorkingDir.getLength() - 1] != '/')
{
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(fileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
+ uWorkingDir += "/";
}
-
- return uUrlFileName;
+ return rtl::Uri::convertRelToAbs(uWorkingDir, fileName);
}
static sal_Bool s_quiet = false;
@@ -363,6 +334,13 @@ static Reference< XSimpleRegistry > openRegistry(
out( ": " );
out( e.Message );
}
+ catch (rtl::MalformedUriException & e)
+ {
+ out( "\n> warning: cannot open registry " );
+ out( rURL );
+ out( ": " );
+ out( e.getMessage() );
+ }
return Reference< XSimpleRegistry >();
}