diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-09-29 13:50:58 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-09-29 13:50:58 +0000 |
commit | d22299433f22110def9077a5fd704c0eb5b0c49a (patch) | |
tree | 1c387eb3f767081f1aecf30a1a0d5a18616d37d7 /desktop | |
parent | fbd3764c623d83884574cc1986b1e723843d9dea (diff) |
CWS-TOOLING: integrate CWS jl112_DEV300
Diffstat (limited to 'desktop')
-rwxr-xr-x | desktop/source/migration/services/extensionmigration.cxx | 60 | ||||
-rwxr-xr-x | desktop/source/migration/services/extensionmigration.hxx | 1 | ||||
-rw-r--r-- | desktop/source/migration/services/makefile.mk | 7 |
3 files changed, 67 insertions, 1 deletions
diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx index cd640d882d..adf2038d8e 100755 --- a/desktop/source/migration/services/extensionmigration.cxx +++ b/desktop/source/migration/services/extensionmigration.cxx @@ -43,9 +43,18 @@ #include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/xml/sax/XParser.hpp" #include "rtl/instance.hxx" +#include "osl/file.hxx" +#include "osl/thread.h" + #include "xmlscript/xmllib_imexp.hxx" #include "../../deployment/inc/dp_ucb.h" +#ifdef SYSTEM_DB +#include <db.h> +#else +#include <berkeleydb/db.h> +#endif + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -310,9 +319,60 @@ namespace migration return true; } + +bool ExtensionMigration::isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir) +{ + try + { + ::rtl::OUString sDb(sSourceDir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "/uno_packages.db"))); + //check if the db exist at all. If not then the call to db_create would create + //the file. + ::osl::File f(sDb); + if (::osl::File::E_None != f.open(OpenFlag_Read)) + { + f.close(); + return false; + } + f.close(); + + //create a system path + ::rtl::OUString sSysPath; + if (::osl::File::getSystemPathFromFileURL(sDb, sSysPath ) != ::osl::File::E_None) + return false; + + ::rtl::OString cstr_sysPath( + ::rtl::OUStringToOString( sSysPath, osl_getThreadTextEncoding() ) ); + char const * pcstr_sysPath = cstr_sysPath.getStr(); + + //Open the db. If it works then we assume that the file was written with a + //compatible version of Berkeley Db + DB* pDB = NULL; + //using DB_RDONLY will return an "Invalid argument" error. + //DB_CREATE: only creates the file if it does not exist. + //An existing db is not modified. + if (0 != db_create(& pDB, 0, DB_CREATE)) + return false; + + if (0 != pDB->open(pDB, 0, pcstr_sysPath , 0, DB_HASH, DB_RDONLY, 0664 /* fs mode */)) + return false; + + pDB->close(pDB, 0); + } + catch (uno::Exception& ) + { + return false; + } + + return true; +} + bool ExtensionMigration::copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) { bool bRet = false; + if (! isCompatibleBerkleyDb(sSourceDir)) + return false; + INetURLObject aSourceObj( sSourceDir ); INetURLObject aDestObj( sTargetDir ); String aName = aDestObj.getName(); diff --git a/desktop/source/migration/services/extensionmigration.hxx b/desktop/source/migration/services/extensionmigration.hxx index b7daa81a8f..58588ceb7d 100755 --- a/desktop/source/migration/services/extensionmigration.hxx +++ b/desktop/source/migration/services/extensionmigration.hxx @@ -88,6 +88,7 @@ namespace migration ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); void copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); + bool isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir); bool copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); bool processExtensions( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); diff --git a/desktop/source/migration/services/makefile.mk b/desktop/source/migration/services/makefile.mk index 86d1371e99..0eb70999e6 100644 --- a/desktop/source/migration/services/makefile.mk +++ b/desktop/source/migration/services/makefile.mk @@ -45,6 +45,10 @@ DLLPRE = .INCLUDE : cppumaker.mk +.IF "$(SYSTEM_DB)" == "YES" +CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) +.ENDIF + SLOFILES= \ $(SLO)$/jvmfwk.obj \ $(SLO)$/cexports.obj \ @@ -67,7 +71,8 @@ SHL1STDLIBS= \ $(I18NISOLANGLIB) \ $(JVMFWKLIB) \ $(COMPHELPERLIB) \ - $(XMLSCRIPTLIB) + $(XMLSCRIPTLIB) \ + $(BERKELEYLIB) |