[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:43:15 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=77235a0

The following commit has been merged in the master branch:
commit 77235a05d01410991924fded2d4f9b97ab68a746
Author: vog <vog at notjusthosting.com>
Date:   Fri Aug 3 16:21:19 2012 +0000

    #836: Copy over xattr (extended attributes, such as resource forks) when creating temporary files
---
 src/basicio.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/basicio.cpp b/src/basicio.cpp
index 2d336ba..bddc3ad 100644
--- a/src/basicio.cpp
+++ b/src/basicio.cpp
@@ -61,6 +61,11 @@ EXIV2_RCSID("@(#) $Id$")
 # include <unistd.h>                    // for getpid, stat
 #endif
 
+// Platform specific headers for handling extended attributes (xattr)
+#if defined(__APPLE__)
+# include <sys/xattr.h>
+#endif
+
 #if defined WIN32 && !defined __CYGWIN__
 // Windows doesn't provide mode_t, nlink_t
 typedef unsigned short mode_t;
@@ -131,6 +136,8 @@ namespace Exiv2 {
         int switchMode(OpMode opMode);
         //! stat wrapper for internal use
         int stat(StructStat& buf) const;
+        //! copy extended attributes (xattr) from another file
+        void copyXattrFrom(const FileIo& src);
 #if defined WIN32 && !defined __CYGWIN__
         // Windows function to determine the number of hardlinks (on NTFS)
         DWORD winNumberOfLinks() const;
@@ -252,6 +259,47 @@ namespace Exiv2 {
         return ret;
     } // FileIo::Impl::stat
 
+    void FileIo::Impl::copyXattrFrom(const FileIo& src)
+    {
+#if defined(__APPLE__)
+# if defined(EXV_UNICODE_PATH)
+#  error No xattr API for MacOS X with unicode support
+# endif
+        const ssize_t namebufSize = ::listxattr(src.p_->path_.c_str(), 0, 0, 0);
+        if (namebufSize < 0) {
+            throw Error(2, src.p_->path_, strError(), "listxattr");
+        }
+        if (namebufSize == 0) {
+            // No extended attributes in source file
+            return;
+        }
+        char namebuf[namebufSize];
+        if (::listxattr(src.p_->path_.c_str(), namebuf, sizeof(namebuf), 0) != namebufSize) {
+            throw Error(2, src.p_->path_, strError(), "listxattr");
+        }
+        for (ssize_t namebufPos = 0; namebufPos < namebufSize;) {
+            const char *name = namebuf + namebufPos;
+            namebufPos += strlen(name) + 1;
+            const ssize_t valueSize = ::getxattr(src.p_->path_.c_str(), name, 0, 0, 0, 0);
+            if (valueSize < 0) {
+                throw Error(2, src.p_->path_, strError(), "getxattr");
+            }
+            char value[valueSize];
+            if (::getxattr(src.p_->path_.c_str(), name, value, sizeof(value), 0, 0) != valueSize) {
+                throw Error(2, src.p_->path_, strError(), "getxattr");
+            }
+#ifdef DEBUG
+            EXV_DEBUG << "Copying xattr \"" << name << "\" with value size " << valueSize << "
";
+#endif
+            if (::setxattr(path_.c_str(), name, value, valueSize, 0, 0) != 0) {
+                throw Error(2, path_, strError(), "setxattr");
+            }
+        }
+#else
+        // No xattr support for this platform.
+#endif
+    } // FileIo::Impl::copyXattrFrom
+
 #if defined WIN32 && !defined __CYGWIN__
     DWORD FileIo::Impl::winNumberOfLinks() const
     {
@@ -521,6 +569,7 @@ namespace Exiv2 {
                     throw Error(10, path(), "w+b", strError());
                 }
             }
+            fileIo->p_->copyXattrFrom(*this);
             basicIo = fileIo;
         }
         else {

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list