[Libreoffice-commits] .: 3 commits - jvmfwk/plugins jvmfwk/prj salhelper/inc salhelper/prj sal/inc

Caolán McNamara caolan at kemper.freedesktop.org
Wed May 25 00:58:13 PDT 2011


 jvmfwk/plugins/sunmajor/pluginlib/makefile.mk |    6 -
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx    |   63 ++++-------------
 jvmfwk/prj/build.lst                          |    2 
 sal/inc/osl/file.hxx                          |    4 -
 salhelper/inc/salhelper/linkhelper.hxx        |   93 ++++++++++++++++++++++++++
 salhelper/prj/d.lst                           |    1 
 6 files changed, 115 insertions(+), 54 deletions(-)

New commits:
commit 393247bbcd572b111c3430dee2081310c1b2185c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed May 25 08:52:54 2011 +0100

    add salhelper::LinkResolver

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
index 9640bf8..5b09a67 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
+++ b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
@@ -59,11 +59,10 @@ SHL1TARGET=	$(UNOCOMPONENT1)
 
 
 SHL1STDLIBS= \
-        $(CPPULIB) \
         $(CPPUHELPER) \
-        $(COMPHELPERLIB) \
-        $(SALLIB) \
-        $(SALHELPERLIB)
+        $(CPPULIB) \
+        $(SALHELPERLIB) \
+        $(SALLIB)
         
 
 .IF "$(GUI)" == "WNT"
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 83d9191..7026893 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -39,7 +39,7 @@
 #include "rtl/byteseq.hxx"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/instance.hxx"
-#include <comphelper/linkhelper.hxx>
+#include <salhelper/linkhelper.hxx>
 #include "boost/scoped_array.hpp"
 #include "com/sun/star/uno/Sequence.hxx"
 #include <utility>
@@ -822,31 +822,21 @@ bool getJREInfoByPath(const rtl::OUString& path,
  */
 OUString resolveDirPath(const OUString & path)
 {
-    OUString sResolved = path;
-
-    if (!comphelper::resolveLink(sResolved))
-        return OUString();
-
     OUString ret;
-
-    //check if this is a directory
-    DirectoryItem item;
-    if (DirectoryItem::get(sResolved, item) == File::E_None)
+    salhelper::LinkResolver aResolver(osl_FileStatus_Mask_Type |
+                                       osl_FileStatus_Mask_FileURL);
+    if (aResolver.fetchFileStatus(path) == osl::FileBase::E_None)
     {
-        FileStatus status(osl_FileStatus_Mask_Type |
-                          osl_FileStatus_Mask_FileURL);
-
-        if (item.getFileStatus(status) == File::E_None
-            && status.getFileType() == FileStatus::Directory)
+        //check if this is a directory
+        if (aResolver.m_aStatus.getFileType() == FileStatus::Directory)
         {
 #ifndef JVM_ONE_PATH_CHECK
-            ret = sResolved;
+            ret = aResolver.m_aStatus.getFileURL();
 #else
             ret = path;
 #endif
         }
     }
-
     return ret;
 }
 /** Checks if the path is a file. If it is a link to a file than
@@ -854,31 +844,21 @@ OUString resolveDirPath(const OUString & path)
  */
 OUString resolveFilePath(const OUString & path)
 {
-    OUString sResolved = path;
-
-    if (!comphelper::resolveLink(sResolved))
-        return OUString();
-
     OUString ret;
-
-    //check if this is a valid path to a file or and if it is a link
-    DirectoryItem item;
-    if (DirectoryItem::get(sResolved, item) == File::E_None)
+    salhelper::LinkResolver aResolver(osl_FileStatus_Mask_Type |
+                                       osl_FileStatus_Mask_FileURL);
+    if (aResolver.fetchFileStatus(path) == osl::FileBase::E_None)
     {
-        FileStatus status(osl_FileStatus_Mask_Type |
-                          osl_FileStatus_Mask_FileURL);
-
-        if (item.getFileStatus(status) == File::E_None
-            && status.getFileType() == FileStatus::Regular)
+        //check if this is a file
+        if (aResolver.m_aStatus.getFileType() == FileStatus::Regular)
         {
 #ifndef JVM_ONE_PATH_CHECK
-            ret = sResolved;
+            ret = aResolver.m_aStatus.getFileURL();
 #else
             ret = path;
 #endif
-        }                    
+        }
     }
-    
     return ret;
 }
 
diff --git a/salhelper/inc/salhelper/linkhelper.hxx b/salhelper/inc/salhelper/linkhelper.hxx
new file mode 100644
index 0000000..c8744dc
--- /dev/null
+++ b/salhelper/inc/salhelper/linkhelper.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _SALHELPER_LINKHELPER_HXX
+#define _SALHELPER_LINKHELPER_HXX
+
+#include <rtl/ustring.hxx>
+#include <osl/file.hxx>
+
+namespace salhelper
+{
+    class LinkResolver
+    {
+    public:
+        osl::FileStatus m_aStatus;
+
+        LinkResolver(sal_uInt32 nMask)
+            : m_aStatus(nMask |
+                        osl_FileStatus_Mask_FileURL |
+                        osl_FileStatus_Mask_Type |
+                        osl_FileStatus_Mask_LinkTargetURL)
+        {
+        }
+
+        /** Resolve a file url if its a symbolic link, to a maximum depth of
+         *  nDepth and fill in m_aStatus with the requested ctor flags
+         *
+         *  @return osl::FileBase::E_None on success
+         *
+         *  @see DirectoryItem::getFileStatus
+         */
+        osl::FileBase::RC fetchFileStatus(const rtl::OUString &rURL,
+            int nDepth = 128)
+        {
+            //In an ideal world this wouldn't be inline, but I want to use this
+            //in jvmfwk hence salhelper, but salhelper is .map controlled and
+            //getting all the mangled names right is a misery, moving it over
+            //to visibility markup would drop per-symbol versioning
+            osl::FileBase::RC eReturn;
+
+            osl::DirectoryItem item;
+            rtl::OUString sURL(rURL);
+            while ((eReturn = osl::DirectoryItem::get(sURL, item))
+                  == osl::File::E_None)
+            {
+                if (--nDepth == 0)
+                {
+                    eReturn = osl::FileBase::E_MULTIHOP;
+                    break;
+                }
+                eReturn = item.getFileStatus(m_aStatus);
+                if (eReturn != osl::File::E_None)
+                    break;
+                if (m_aStatus.getFileType() != osl::FileStatus::Link)
+                {
+                    eReturn = osl::FileBase::E_None;
+                    break;
+                }
+                sURL = m_aStatus.getLinkTargetURL();
+            }
+
+            return eReturn;
+        }
+    };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/salhelper/prj/d.lst b/salhelper/prj/d.lst
index 86b44d0..a0769a4 100644
--- a/salhelper/prj/d.lst
+++ b/salhelper/prj/d.lst
@@ -6,6 +6,7 @@ mkdir: %_DEST%\inc%_EXT%\salhelper
 ..\inc\salhelper\futurequeue.hxx %_DEST%\inc%_EXT%\salhelper\futurequeue.hxx
 ..\inc\salhelper\monitor.hxx %_DEST%\inc%_EXT%\salhelper\monitor.hxx
 ..\inc\salhelper\queue.hxx %_DEST%\inc%_EXT%\salhelper\queue.hxx
+..\inc\salhelper\linkhelper.hxx %_DEST%\inc%_EXT%\salhelper\linkhelper.hxx
 ..\inc\salhelper\refobj.hxx %_DEST%\inc%_EXT%\salhelper\refobj.hxx
 ..\inc\salhelper\simplereferenceobject.hxx %_DEST%\inc%_EXT%\salhelper\simplereferenceobject.hxx
 ..\inc\salhelper\singletonref.hxx %_DEST%\inc%_EXT%\salhelper\singletonref.hxx
commit ff83c1d1a6eec0070b7a7351bb8d50db6edbc9d0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 24 20:57:33 2011 +0100

    fix flaggs typo

diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx
index 7ca79ef..e75b591 100644
--- a/sal/inc/osl/file.hxx
+++ b/sal/inc/osl/file.hxx
@@ -466,7 +466,7 @@ public:
     /** Constructor.
 
         @param nMask 
-        Set of flaggs decribing the demanded information.
+        Set of flags decribing the demanded information.
     */
 
     VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
@@ -714,7 +714,7 @@ public:
     /** Constructor.
 
         @param nMask
-        Set of flaggs decribing the demanded information.
+        Set of flags decribing the demanded information.
     */
 
     FileStatus( sal_uInt32 nMask ): _nMask( nMask ) 
commit 70d661eb82aad0be5cb3925c4251fa3099b11253
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 24 16:31:38 2011 +0100

    use comphelper::resolveLink

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
index 76fd7c9..9640bf8 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
+++ b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk
@@ -61,6 +61,7 @@ SHL1TARGET=	$(UNOCOMPONENT1)
 SHL1STDLIBS= \
         $(CPPULIB) \
         $(CPPUHELPER) \
+        $(COMPHELPERLIB) \
         $(SALLIB) \
         $(SALHELPERLIB)
         
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 605dc27..83d9191 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -39,6 +39,7 @@
 #include "rtl/byteseq.hxx"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/instance.hxx"
+#include <comphelper/linkhelper.hxx>
 #include "boost/scoped_array.hpp"
 #include "com/sun/star/uno/Sequence.hxx"
 #include <utility>
@@ -59,6 +60,7 @@
 #include "sunjre.hxx"
 #include "vendorlist.hxx"
 #include "diagnostics.h"
+
 using namespace osl;
 using namespace std;
 
@@ -820,32 +822,20 @@ bool getJREInfoByPath(const rtl::OUString& path,
  */
 OUString resolveDirPath(const OUString & path)
 {
-    OUString ret;
-    OUString sResolved;
-    //getAbsoluteFileURL also resolves links
-    if (File::getAbsoluteFileURL(
-            OUSTR("file:///"), path, sResolved) != File::E_None)
+    OUString sResolved = path;
+
+    if (!comphelper::resolveLink(sResolved))
         return OUString();
 
-    //check if this is a valid path and if it is a directory
+    OUString ret;
+
+    //check if this is a directory
     DirectoryItem item;
     if (DirectoryItem::get(sResolved, item) == File::E_None)
     {
         FileStatus status(osl_FileStatus_Mask_Type |
-                          osl_FileStatus_Mask_LinkTargetURL |
                           osl_FileStatus_Mask_FileURL);
 
-        int nDepth = 0;
-        while (item.getFileStatus(status) == File::E_None &&
-               status.getFileType() == FileStatus::Link)
-        {
-            if (++nDepth == 128)
-                break;
-            sResolved = status.getLinkTargetURL();
-            if (DirectoryItem::get(sResolved, item) != File::E_None)
-                break;
-        }
-
         if (item.getFileStatus(status) == File::E_None
             && status.getFileType() == FileStatus::Directory)
         {
@@ -856,8 +846,7 @@ OUString resolveDirPath(const OUString & path)
 #endif
         }
     }
-    else
-        return OUString();
+
     return ret;
 }
 /** Checks if the path is a file. If it is a link to a file than
@@ -865,20 +854,20 @@ OUString resolveDirPath(const OUString & path)
  */
 OUString resolveFilePath(const OUString & path)
 {
-    OUString ret;
-    OUString sResolved;
+    OUString sResolved = path;
 
-    if (File::getAbsoluteFileURL(
-            OUSTR("file:///"), path, sResolved) != File::E_None)
+    if (!comphelper::resolveLink(sResolved))
         return OUString();
 
+    OUString ret;
+
     //check if this is a valid path to a file or and if it is a link
     DirectoryItem item;
     if (DirectoryItem::get(sResolved, item) == File::E_None)
     {
         FileStatus status(osl_FileStatus_Mask_Type |
-                          osl_FileStatus_Mask_LinkTargetURL |
                           osl_FileStatus_Mask_FileURL);
+
         if (item.getFileStatus(status) == File::E_None
             && status.getFileType() == FileStatus::Regular)
         {
@@ -889,8 +878,6 @@ OUString resolveFilePath(const OUString & path)
 #endif
         }                    
     }
-    else
-        return OUString();
     
     return ret;
 }
diff --git a/jvmfwk/prj/build.lst b/jvmfwk/prj/build.lst
index bd09aae..1a8d674 100644
--- a/jvmfwk/prj/build.lst
+++ b/jvmfwk/prj/build.lst
@@ -1,4 +1,4 @@
-jvmf jvmfwk : cppu cppuhelper sal LIBXML2:libxml2 NULL
+jvmf jvmfwk : cppu cppuhelper sal comphelper LIBXML2:libxml2 NULL
 jvmf jvmfwk\inc nmake - all jvmf_inc NULL
 jvmf jvmfwk\source nmake - all jvmf_framework jvmf_inc NULL
 jvmf jvmfwk\plugins\sunmajor\pluginlib nmake - all jvmf_sunmajorlib jvmf_inc NULL


More information about the Libreoffice-commits mailing list