diff options
author | obo <obo@openoffice.org> | 2011-03-16 10:11:17 +0100 |
---|---|---|
committer | obo <obo@openoffice.org> | 2011-03-16 10:11:17 +0100 |
commit | 160329d6fb16c593f651fc143f5a8973566c6c22 (patch) | |
tree | 4c86997b65d9e1a5d00d62d110658cc3b8f18a7f /desktop | |
parent | b4aafb548412bb91974656a9b0801524b20ab6c9 (diff) | |
parent | 271137c2c5d3bcacdee5cf15b8df9138345316ed (diff) |
CWS-TOOLING: integrate CWS jl164
Diffstat (limited to 'desktop')
-rwxr-xr-x[-rw-r--r--] | desktop/source/deployment/manager/dp_manager.cxx | 22 | ||||
-rw-r--r--[-rwxr-xr-x] | desktop/source/deployment/registry/dp_backend.cxx | 59 | ||||
-rwxr-xr-x[-rw-r--r--] | desktop/source/deployment/registry/dp_backenddb.cxx | 5 |
3 files changed, 41 insertions, 45 deletions
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 2e2c5e2a2f53..89ab4d0b7199 100644..100755 --- 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 <vector> @@ -636,21 +637,12 @@ OUString PackageManagerImpl::insertToActivationLayer( ::ucbhelper::Content sourceContent(sourceContent_); Reference<XCommandEnvironment> 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 ); - if (m_activePackages_expanded.getLength() == 0) { - destFolder = tempEntry; - } - else { - tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); - // tweak user|share to macrofied url: - destFolder = makeURL( m_activePackages, tempEntry ); - } + + String baseDir(m_activePackages_expanded); + ::utl::TempFile aTemp(&baseDir, sal_False); + OUString tempEntry = aTemp.GetURL(); + tempEntry = tempEntry.copy(tempEntry.lastIndexOf('/') + 1); + OUString destFolder = makeURL( m_activePackages, tempEntry); destFolder += OUSTR("_"); // prepare activation folder: diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 266d4406cfde..32413f3d11ba 100755..100644 --- 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<ucb::XCommandEnvironment> 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<XCommandEnvironment>(), false /* no throw: ignore errors */ ); - erase_path( tempFile, Reference<XCommandEnvironment>(), - false /* no throw: ignore errors */ ); + + if (folderUrl[folderUrl.getLength() - 1] == '_') + { + const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1); + erase_path( tempFile, Reference<XCommandEnvironment>(), + 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<sdbc::XResultSet> xResultSet( tempFolder.createCursor( Sequence<OUString>( &StrTitle::get(), 1 ), - ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); // get all temp directories: ::std::vector<OUString> 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]); } } } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 9629855aaf11..44e11efdef0e 100644..100755 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -91,7 +91,10 @@ css::uno::Reference<css::xml::dom::XDocument> 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<css::ucb::XCommandEnvironment>()); + Reference<css::io::XInputStream> xIn = descContent.openStream(); + m_doc = xDocBuilder->parse(xIn); } else if (err == ::osl::File::E_NOENT) { |