diff options
author | Juergen Schmidt <jsc@openoffice.org> | 2001-08-17 12:09:50 +0000 |
---|---|---|
committer | Juergen Schmidt <jsc@openoffice.org> | 2001-08-17 12:09:50 +0000 |
commit | a87e0923371a1821bc3bdb37515e15d831a4b113 (patch) | |
tree | 66af42686e353cb2d05ef73a3d3a320f1c949835 /cpputools | |
parent | 4aee767252a8e145a5ac78654ecc01cc9bb2986d (diff) |
#91088# convert registry path to URL
Diffstat (limited to 'cpputools')
-rw-r--r-- | cpputools/source/registercomponent/registercomponent.cxx | 63 | ||||
-rw-r--r-- | cpputools/source/unoexe/unoexe.cxx | 51 |
2 files changed, 102 insertions, 12 deletions
diff --git a/cpputools/source/registercomponent/registercomponent.cxx b/cpputools/source/registercomponent/registercomponent.cxx index dd71290dd122..11f64a801f66 100644 --- a/cpputools/source/registercomponent/registercomponent.cxx +++ b/cpputools/source/registercomponent/registercomponent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: registercomponent.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jsc $ $Date: 2001-02-19 16:24:38 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:00:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,16 +64,63 @@ #include <vector> -#ifndef _OSL_THREAD_H_ -#include <osl/thread.h> -#endif - #include <cppuhelper/servicefactory.hxx> #include <com/sun/star/registry/XImplementationRegistration.hpp> #include <com/sun/star/registry/XSimpleRegistry.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <algorithm> + +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; + +sal_Bool isFileUrl(const OUString& fileName) +{ + if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 ) + return sal_True; + return sal_False; +} + +OUString convertToFileUrl(const OUString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return fileName; + } + + OUString uUrlFileName; + if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + { + OUString uWorkingDir; + OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None ); + OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName) == FileBase::E_None ); + } else + { + OSL_VERIFY( FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) == FileBase::E_None ); + } + + return uUrlFileName; +} + static void usingRegisterImpl() { fprintf(stderr, "\nusing: regcomp -register|revoke -r registryfile -c locationUrl [-br registryfile] [-l componentLoaderUrl]\n"); @@ -424,7 +471,7 @@ void _cdecl main( int argc, char * argv[] ) { if ( aOptions.sBootRegName.getLength() ) { - xSMgr = createRegistryServiceFactory( aOptions.sBootRegName ); + xSMgr = createRegistryServiceFactory( convertToFileUrl(aOptions.sBootRegName) ); } else { xSMgr = createServiceFactory(); @@ -468,7 +515,7 @@ void _cdecl main( int argc, char * argv[] ) { try { - xReg->open( aOptions.sRegName, sal_False, sal_True); + xReg->open( convertToFileUrl(aOptions.sRegName), sal_False, sal_True); if (!xReg->isValid()) { fprintf(stderr, "ERROR: open|create registry \"%s\" failed!\n", sRegName.getStr()); diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index 5b86e8569f75..7cfe761e55e6 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unoexe.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: dbo $ $Date: 2001-06-29 08:59:01 $ + * last change: $Author: jsc $ $Date: 2001-08-17 12:59:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,6 +96,22 @@ #include <com/sun/star/bridge/XBridgeFactory.hpp> #include <com/sun/star/bridge/XBridge.hpp> +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + using namespace std; using namespace rtl; using namespace osl; @@ -108,10 +124,37 @@ using namespace com::sun::star::connection; using namespace com::sun::star::bridge; using namespace com::sun::star::container; - namespace unoexe { +static sal_Bool isFileUrl(const OUString& fileName) +{ + if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 ) + return sal_True; + return sal_False; +} + +static OUString convertToFileUrl(const OUString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return fileName; + } + + OUString uUrlFileName; + if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + { + OUString uWorkingDir; + OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None ); + OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName) == FileBase::E_None ); + } else + { + OSL_VERIFY( FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) == FileBase::E_None ); + } + + return uUrlFileName; +} + //-------------------------------------------------------------------------------------------------- static inline void out( const sal_Char * pText ) { @@ -329,7 +372,7 @@ static Reference< XSimpleRegistry > openRegistry( try { - xNewReg->open( rURL, bReadOnly, bCreate ); + xNewReg->open( convertToFileUrl(rURL), bReadOnly, bCreate ); if (xNewReg->isValid()) return xNewReg; else |