diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-03-09 17:02:32 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-03-09 17:03:48 +0000 |
commit | d3192948fe968fc4d6a8ec0e6fda232f265b3c4c (patch) | |
tree | ec29e620f35986ee17bbd6ad328cff0baad0d1a3 /desktop/source/deployment | |
parent | 2d5c1a3f6de583629c29fc0eeea630c8f8a0eb89 (diff) |
fdo#40607 - osl_syncFile having written, and avoid doing that on start
Diffstat (limited to 'desktop/source/deployment')
-rw-r--r-- | desktop/source/deployment/manager/dp_manager.cxx | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 4f6f6c048870..0efa4c09036b 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -311,6 +311,36 @@ void PackageManagerImpl::initRegistryBackends() m_xComponentContext ) ); } +// this overcomes previous rumours that the sal API is misleading +// as to whether a directory is truly read-only or not +static bool isMacroURLWriteable( const OUString &rMacro ) +{ + if (rMacro.getLength() < (sal_Int32)sizeof ("vnd.sun.star.expand:")) + return true; + rtl::OUString aURL( rMacro.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); + ::rtl::Bootstrap::expandMacros( aURL ); + + bool bError; + sal_uInt64 nWritten = 0; + ::osl::File aFile( aURL ); + + bError = aFile.open( osl_File_OpenFlag_Read | + osl_File_OpenFlag_Write | + osl_File_OpenFlag_Create ) != ::osl::FileBase::E_None; + if (!bError) + bError = aFile.write( "1", 1, nWritten ) != ::osl::FileBase::E_None; + if (aFile.close() != ::osl::FileBase::E_None) + bError = true; + if (osl::File::remove( aURL ) != ::osl::FileBase::E_None) + bError = true; + + OSL_TRACE ("local url '%s' -> '%s' %s readonly\n", + rtl::OUStringToOString( rMacro, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr(), + bError ? "is" : "is not"); + return bError; +} + //______________________________________________________________________________ Reference<deployment::XPackageManager> PackageManagerImpl::create( Reference<XComponentContext> const & xComponentContext, @@ -406,39 +436,9 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create( Reference<XCommandEnvironment> xCmdEnv; try { - //There is no stampURL for the bundled folder + // There is no stampURL for the bundled folder if (!stampURL.isEmpty()) - { -#define CURRENT_STAMP "1" - try { - //The osl file API does not allow to find out if one can write - //into a folder. Therefore we try to write a file. Then we delete - //it, so that it does not hinder uninstallation of OOo - // probe writing: - ::ucbhelper::Content ucbStamp( stampURL, xCmdEnv ); - ::rtl::OString stamp( - RTL_CONSTASCII_STRINGPARAM(CURRENT_STAMP) ); - Reference<io::XInputStream> xData( - ::xmlscript::createInputStream( - ::rtl::ByteSequence( - reinterpret_cast<sal_Int8 const *>(stamp.getStr()), - stamp.getLength() ) ) ); - ucbStamp.writeStream( xData, true /* replace existing */ ); - that->m_readOnly = false; - erase_path( stampURL, xCmdEnv ); - } - catch (const RuntimeException &) { - try { - erase_path( stampURL, xCmdEnv ); - } catch (...) - { - } - throw; - } - catch (const Exception &) { - that->m_readOnly = true; - } - } + that->m_readOnly = !isMacroURLWriteable( stampURL ); if (!that->m_readOnly && !logFile.isEmpty()) { |