diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-01-31 11:44:20 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-01-31 11:44:20 +0100 |
commit | b01ec28b6dfa84c9c9f07d08af27a0107a5260a1 (patch) | |
tree | 2891b61ba6bf9ff7ff740618b5ae8eb059e1ce6e /desktop/source | |
parent | 9f440258b6bdf9b168992f7058f448dac588760c (diff) |
Create missing parent dirs when checking for r/o dir
...can happen when 'unopkg add' is called before soffice had ever been run, so
UserInstallation isn't populated yet
Change-Id: I0c6b9444f196da5ad5a32cc90f2e1e2a5dbd0f58
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/deployment/manager/dp_manager.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index c47aad7bbbb8..ff675b91ac07 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -30,6 +30,7 @@ #include <rtl/uri.hxx> #include <rtl/bootstrap.hxx> #include <sal/log.hxx> +#include <tools/urlobj.hxx> #include <osl/diagnose.h> #include <osl/file.hxx> #include <osl/security.hxx> @@ -278,14 +279,32 @@ void PackageManagerImpl::initRegistryBackends() m_xComponentContext ) ); } +namespace { + +osl::FileBase::RC createDirectory(OUString const & url) { + auto e = osl::Directory::create(url); + if (e != osl::FileBase::E_NOENT) { + return e; + } + INetURLObject o(url); + if (!o.removeSegment()) { + return osl::FileBase::E_INVAL; // anything but E_None/E_EXIST + } + e = createDirectory(o.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + if (e != osl::FileBase::E_None && e != osl::FileBase::E_EXIST) { + return e; + } + return osl::Directory::create(url); +} + // this overcomes previous rumors that the sal API is misleading // as to whether a directory is truly read-only or not -static bool isMacroURLReadOnly( const OUString &rMacro ) +bool isMacroURLReadOnly( const OUString &rMacro ) { OUString aDirURL( rMacro ); ::rtl::Bootstrap::expandMacros( aDirURL ); - ::osl::FileBase::RC aErr = ::osl::Directory::create( aDirURL ); + ::osl::FileBase::RC aErr = createDirectory( aDirURL ); if ( aErr == ::osl::FileBase::E_None ) return false; // it will be writeable if ( aErr != ::osl::FileBase::E_EXIST ) @@ -313,6 +332,7 @@ static bool isMacroURLReadOnly( const OUString &rMacro ) return bError; } +} Reference<deployment::XPackageManager> PackageManagerImpl::create( Reference<XComponentContext> const & xComponentContext, |