From bf2af8dbb892d5f6b66a786ce75459a0de4c9477 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 18 Feb 2011 17:17:49 +0100 Subject: jl64 #i109096# extensions do not work with long path names --- desktop/source/deployment/manager/dp_manager.cxx | 29 ++++++++++++++-------- .../source/deployment/registry/dp_backenddb.cxx | 5 +++- 2 files changed, 23 insertions(+), 11 deletions(-) mode change 100644 => 100755 desktop/source/deployment/manager/dp_manager.cxx mode change 100644 => 100755 desktop/source/deployment/registry/dp_backenddb.cxx (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx old mode 100644 new mode 100755 index 2e2c5e2a2f53..ad01a9dbb79e --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -63,6 +63,7 @@ #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "boost/bind.hpp" #include "tools/urlobj.hxx" +#include "unotools/tempfile.hxx" #include "osl/file.hxx" #include @@ -636,20 +637,28 @@ OUString PackageManagerImpl::insertToActivationLayer( ::ucbhelper::Content sourceContent(sourceContent_); Reference xCmdEnv( sourceContent.getCommandEnvironment() ); - OUString destFolder, tempEntry; - if (::osl::File::createTempFile( - m_activePackages_expanded.getLength() == 0 - ? 0 : &m_activePackages_expanded, - 0, &tempEntry ) != ::osl::File::E_None) - throw RuntimeException( - OUSTR("::osl::File::createTempFile() failed!"), 0 ); + OUString destFolder; + OUString tempEntry; + // if (::osl::File::createTempFile( + // m_activePackages_expanded.getLength() == 0 + // ? 0 : &m_activePackages_expanded, + // 0, &tempEntry ) != ::osl::File::E_None) + // throw RuntimeException( + // OUSTR("::osl::File::createTempFile() failed!"), 0 ); + //::utl::TempFile::SetTempNameBaseDirectory(m_activePackages_expanded); + String baseDir(m_activePackages_expanded); + ::utl::TempFile aTemp(OUSTR("jl123"), NULL, &baseDir, sal_False); if (m_activePackages_expanded.getLength() == 0) { - destFolder = tempEntry; +// destFolder = tempEntry; + destFolder = aTemp.GetFileName(); } else { - tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); +// tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); // tweak user|share to macrofied url: - destFolder = makeURL( m_activePackages, tempEntry ); +// destFolder = makeURL( m_activePackages, tempEntry ); + tempEntry = aTemp.GetURL(); + tempEntry = tempEntry.copy(tempEntry.lastIndexOf('/') + 1); + destFolder = makeURL( m_activePackages, tempEntry); } destFolder += OUSTR("_"); diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx old mode 100644 new mode 100755 index 9629855aaf11..44e11efdef0e --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -91,7 +91,10 @@ css::uno::Reference BackendDb::getDocument() ::osl::File::RC err = ::osl::DirectoryItem::get(m_urlDb, item); if (err == ::osl::File::E_None) { - m_doc = xDocBuilder->parseURI(m_urlDb); + ::ucbhelper::Content descContent( + m_urlDb, css::uno::Reference()); + Reference xIn = descContent.openStream(); + m_doc = xDocBuilder->parse(xIn); } else if (err == ::osl::File::E_NOENT) { -- cgit From 1e65d22b7ce7d3f65f730dbd788fc4423b707a5e Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 21 Feb 2011 15:37:12 +0100 Subject: jl164 #i109096# folders in configuration and help registry folders are now created with unotools::TempFile. --- desktop/source/deployment/manager/dp_manager.cxx | 2 +- desktop/source/deployment/registry/dp_backend.cxx | 59 ++++++++++++----------- 2 files changed, 31 insertions(+), 30 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index ad01a9dbb79e..0339cf599b34 100755 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -647,7 +647,7 @@ OUString PackageManagerImpl::insertToActivationLayer( // OUSTR("::osl::File::createTempFile() failed!"), 0 ); //::utl::TempFile::SetTempNameBaseDirectory(m_activePackages_expanded); String baseDir(m_activePackages_expanded); - ::utl::TempFile aTemp(OUSTR("jl123"), NULL, &baseDir, sal_False); + ::utl::TempFile aTemp(&baseDir, sal_False); if (m_activePackages_expanded.getLength() == 0) { // destFolder = tempEntry; destFolder = aTemp.GetFileName(); diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 266d4406cfde..32413f3d11ba 100755 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -45,6 +45,7 @@ #include "com/sun/star/beans/StringPair.hpp" #include "com/sun/star/sdbc/XResultSet.hpp" #include "com/sun/star/sdbc/XRow.hpp" +#include "unotools/tempfile.hxx" using namespace ::dp_misc; @@ -225,42 +226,43 @@ OUString PackageRegistryBackend::createFolder( OUString const & relUrl, Reference const & xCmdEnv) { - OUString sDataFolder = makeURL(getCachePath(), relUrl); + const OUString sDataFolder = makeURL(getCachePath(), relUrl); //make sure the folder exist ucbhelper::Content dataContent; ::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv); - OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder); - - OUString tempEntry; - if (::osl::File::createTempFile( - &sDataFolderURL, 0, &tempEntry ) != ::osl::File::E_None) - throw RuntimeException( - OUSTR("::osl::File::createTempFile() failed!"), 0 ); - tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); - OUString destFolder= makeURL(sDataFolder, tempEntry) + OUSTR("_"); - ::ucbhelper::Content destFolderContent; - dp_misc::create_folder( &destFolderContent, destFolder, xCmdEnv ); - - return destFolder; + const OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder); + const String baseDir(sDataFolder); + const ::utl::TempFile aTemp(&baseDir, sal_True); + const OUString url = aTemp.GetURL(); + return sDataFolder + url.copy(url.lastIndexOf('/')); } +//folderURL can have the extension .tmp or .tmp_ +//Before OOo 3.4 the created a tmp file with osl_createTempFile and +//then created a Folder with a same name and a trailing '_' +//If the folderURL has no '_' then there is no corresponding tmp file. void PackageRegistryBackend::deleteTempFolder( OUString const & folderUrl) { - OSL_ASSERT(folderUrl.getLength() - && folderUrl[folderUrl.getLength() - 1] == '_'); - if (folderUrl.getLength() - && folderUrl[folderUrl.getLength() - 1] == '_') + if (folderUrl.getLength()) { - const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1); erase_path( folderUrl, Reference(), false /* no throw: ignore errors */ ); - erase_path( tempFile, Reference(), - false /* no throw: ignore errors */ ); + + if (folderUrl[folderUrl.getLength() - 1] == '_') + { + const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1); + erase_path( tempFile, Reference(), + false /* no throw: ignore errors */ ); + } } } +//usedFolders can contain folder names which have the extension .tmp or .tmp_ +//Before OOo 3.4 we created a tmp file with osl_createTempFile and +//then created a Folder with a same name and a trailing '_' +//If the folderURL has no '_' then there is no corresponding tmp file. void PackageRegistryBackend::deleteUnusedFolders( OUString const & relUrl, ::std::list< OUString> const & usedFolders) @@ -273,12 +275,14 @@ void PackageRegistryBackend::deleteUnusedFolders( Reference xResultSet( tempFolder.createCursor( Sequence( &StrTitle::get(), 1 ), - ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); // get all temp directories: ::std::vector tempEntries; char tmp[] = ".tmp"; + //Check for ".tmp_" can be removed after OOo 4.0 + char tmp_[] = ".tmp_"; while (xResultSet->next()) { OUString title( @@ -286,21 +290,18 @@ void PackageRegistryBackend::deleteUnusedFolders( xResultSet, UNO_QUERY_THROW )->getString( 1 /* Title */ ) ); - if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1)) + if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1) + || title.endsWithAsciiL(tmp_, sizeof(tmp_) - 1)) tempEntries.push_back( makeURLAppendSysPathSegment(sDataFolder, title)); } for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos ) { - //usedFolders contains the urls to the folders which have - //a trailing underscore - const OUString tempFolderName = tempEntries[ pos ] + OUSTR("_"); - - if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == + if (::std::find( usedFolders.begin(), usedFolders.end(), tempEntries[pos] ) == usedFolders.end()) { - deleteTempFolder(tempFolderName); + deleteTempFolder(tempEntries[pos]); } } } -- cgit From fd2597bbeb3f9ef2a803615ff4df1aea10242283 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 24 Feb 2011 15:28:48 +0100 Subject: jl164 #i109096# libxml2 fails when using long paths on windows --- desktop/source/deployment/manager/dp_manager.cxx | 25 ++++-------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 0339cf599b34..89ab4d0b7199 100755 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -637,29 +637,12 @@ OUString PackageManagerImpl::insertToActivationLayer( ::ucbhelper::Content sourceContent(sourceContent_); Reference xCmdEnv( sourceContent.getCommandEnvironment() ); - OUString destFolder; - OUString tempEntry; - // if (::osl::File::createTempFile( - // m_activePackages_expanded.getLength() == 0 - // ? 0 : &m_activePackages_expanded, - // 0, &tempEntry ) != ::osl::File::E_None) - // throw RuntimeException( - // OUSTR("::osl::File::createTempFile() failed!"), 0 ); - //::utl::TempFile::SetTempNameBaseDirectory(m_activePackages_expanded); + String baseDir(m_activePackages_expanded); ::utl::TempFile aTemp(&baseDir, sal_False); - if (m_activePackages_expanded.getLength() == 0) { -// destFolder = tempEntry; - destFolder = aTemp.GetFileName(); - } - else { -// tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); - // tweak user|share to macrofied url: -// destFolder = makeURL( m_activePackages, tempEntry ); - tempEntry = aTemp.GetURL(); - tempEntry = tempEntry.copy(tempEntry.lastIndexOf('/') + 1); - destFolder = makeURL( m_activePackages, tempEntry); - } + OUString tempEntry = aTemp.GetURL(); + tempEntry = tempEntry.copy(tempEntry.lastIndexOf('/') + 1); + OUString destFolder = makeURL( m_activePackages, tempEntry); destFolder += OUSTR("_"); // prepare activation folder: -- cgit