[Libreoffice-commits] core.git: desktop/source

Stephan Bergmann sbergman at redhat.com
Tue Jan 31 10:45:59 UTC 2017


 desktop/source/deployment/manager/dp_manager.cxx |   24 +++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

New commits:
commit b01ec28b6dfa84c9c9f07d08af27a0107a5260a1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 31 11:44:20 2017 +0100

    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

diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index c47aad7..ff675b9 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,


More information about the Libreoffice-commits mailing list