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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:36:16 UTC 2017


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

The following commit has been merged in the master branch:
commit 99a87043a4943feaafc4643aedf6c924d9f0cc32
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Fri Apr 23 13:55:42 2004 +0000

    Workaround for MinGW bug: use remove() before rename()
---
 src/actions.cpp | 12 +++++++-----
 src/exif.cpp    | 10 ++++++----
 src/image.cpp   | 41 ++++++++++++++++++++++-------------------
 src/image.hpp   | 50 +++++---------------------------------------------
 4 files changed, 40 insertions(+), 73 deletions(-)

diff --git a/src/actions.cpp b/src/actions.cpp
index c13534d..9fa7bcf 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -20,13 +20,13 @@
  */
 /*
   File:      actions.cpp
-  Version:   $Name:  $ $Revision: 1.16 $
+  Version:   $Name:  $ $Revision: 1.17 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History:   08-Dec-03, ahu: created
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.16 $ $RCSfile: actions.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.17 $ $RCSfile: actions.cpp,v $")
 
 // *****************************************************************************
 // included header files
@@ -495,8 +495,10 @@ namespace Action {
             std::cin >> s;
             if (s[0] != 'y' && s[0] != 'Y') return 0;
         }
+        // Workaround for MinGW rename which does not overwrite existing files
+        ::remove(newPath.c_str());
         if (::rename(path.c_str(), newPath.c_str()) == -1) {
-            std::cerr << Params::instance().progname()  
+            std::cerr << Params::instance().progname()
                       << ": Failed to rename "
                       << path << " to " << newPath << ": "
                       << Util::strError() << "
";
@@ -756,7 +758,7 @@ namespace Action {
             return 1;
         }
         if (Params::instance().verbose_) {
-            std::cout << "Adjusting '" << md->tagName() << "' by" 
+            std::cout << path << ": Adjusting timestamp by" 
                       << (adjustment_ < 0 ? " " : " +")
                       << adjustment_ << " seconds to ";
         }
@@ -868,7 +870,7 @@ namespace {
             error = "Couldn't open temporary file";
             break;
         case -4:
-            error = "Renaming temporary file failed";
+            error = "Renaming temporary file failed: " + Util::strError();
             break;
         case 1:
             error = "Couldn't read from the input stream";
diff --git a/src/exif.cpp b/src/exif.cpp
index 32ef94a..c571003 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -20,14 +20,14 @@
  */
 /*
   File:      exif.cpp
-  Version:   $Name:  $ $Revision: 1.38 $
+  Version:   $Name:  $ $Revision: 1.39 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History:   26-Jan-04, ahu: created
              11-Feb-04, ahu: isolated as a component
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.38 $ $RCSfile: exif.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.39 $ $RCSfile: exif.cpp,v $")
 
 // Define DEBUG_MAKERNOTE to output debug information to std::cerr
 #undef DEBUG_MAKERNOTE
@@ -594,9 +594,10 @@ namespace Exif {
         std::ifstream is(path.c_str(), std::ios::binary);
         if (!is) return -1;
         Image* pImage = ImageFactory::instance().create(is);
+        is.close();
         if (pImage == 0) return -2;
 
-        int rc = pImage->eraseExifData(path, is);
+        int rc = pImage->eraseExifData(path);
         delete pImage;
         return rc;
     } // ExifData::erase
@@ -606,6 +607,7 @@ namespace Exif {
         std::ifstream is(path.c_str(), std::ios::binary);
         if (!is) return -1;
         Image* pImage = ImageFactory::instance().create(is);
+        is.close();
         if (pImage == 0) return -2;
 
         DataBuf buf(size());
@@ -613,7 +615,7 @@ namespace Exif {
         assert(actualSize <= buf.size_);
 
         pImage->setExifData(buf.pData_, actualSize);
-        int rc = pImage->writeExifData(path, is);
+        int rc = pImage->writeExifData(path);
         delete pImage;
         return rc;
     } // ExifData::write
diff --git a/src/image.cpp b/src/image.cpp
index e2af863..50e372d 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -20,14 +20,14 @@
  */
 /*
   File:      image.cpp
-  Version:   $Name:  $ $Revision: 1.11 $
+  Version:   $Name:  $ $Revision: 1.12 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History:   26-Jan-04, ahu: created
              11-Feb-04, ahu: isolated as a component
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.11 $ $RCSfile: image.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.12 $ $RCSfile: image.cpp,v $")
 
 // *****************************************************************************
 // included header files
@@ -38,9 +38,9 @@ EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.11 $ $RCSfile: image.cpp,v $")
 #include <iostream>
 #include <fstream>
 #include <cstring>
-#include <cstdio>                               // for rename
+#include <cstdio>                               // for rename, remove
 #include <sys/types.h>                          // for getpid
-#include <unistd.h>                             // for getpid, unlink
+#include <unistd.h>                             // for getpid
 
 // *****************************************************************************
 // class member definitions
@@ -189,13 +189,10 @@ namespace Exif {
 
     int JpegImage::eraseExifData(const std::string& path) const
     {
-        std::ifstream infile(path.c_str(), std::ios::binary);
-        if (!infile) return -1;
-        return eraseExifData(path, infile);
-    } // JpegImage::eraseExifData
+        // Open input file
+        std::ifstream is(path.c_str(), std::ios::binary);
+        if (!is) return -1;
 
-    int JpegImage::eraseExifData(const std::string& path, std::istream& is) const
-    {
         // Write the output to a temporary file
         pid_t pid = getpid();
         std::string tmpname = path + toString(pid);
@@ -204,13 +201,18 @@ namespace Exif {
 
         int rc = eraseExifData(os, is);
         os.close();
+        is.close();
+        if (rc == 0) {
+            // Workaround for MinGW rename that does not overwrite existing files
+            if (remove(path.c_str()) != 0) rc = -4;
+        }
         if (rc == 0) {
             // rename temporary file
             if (rename(tmpname.c_str(), path.c_str()) == -1) rc = -4;
         }
         if (rc != 0) {
             // remove temporary file
-            unlink(tmpname.c_str());
+            remove(tmpname.c_str());
         }
 
         return rc;
@@ -219,7 +221,6 @@ namespace Exif {
     // Todo: implement this properly: skip unknown APP0 and APP1 segments
     int JpegImage::eraseExifData(std::ostream& os, std::istream& is) const
     {
-
         // Check if this is a JPEG image in the first place
         if (!isThisType(is, true)) {
             if (!is.good()) return 1;
@@ -286,13 +287,10 @@ namespace Exif {
 
     int JpegImage::writeExifData(const std::string& path) const
     {
-        std::ifstream infile(path.c_str(), std::ios::binary);
-        if (!infile) return -1;
-        return writeExifData(path, infile);
-    } // JpegImage::writeExifData
+        // Open the input file
+        std::ifstream is(path.c_str(), std::ios::binary);
+        if (!is) return -1;
 
-    int JpegImage::writeExifData(const std::string& path, std::istream& is) const
-    {
         // Write the output to a temporary file
         pid_t pid = getpid();
         std::string tmpname = path + toString(pid);
@@ -301,13 +299,18 @@ namespace Exif {
 
         int rc = writeExifData(os, is);
         os.close();
+        is.close();
+        if (rc == 0) {
+            // Workaround for MinGW rename that does not overwrite existing files
+            if (remove(path.c_str()) != 0) rc = -4;
+        }
         if (rc == 0) {
             // rename temporary file
             if (rename(tmpname.c_str(), path.c_str()) == -1) rc = -4;
         }
         if (rc != 0) {
             // remove temporary file
-            unlink(tmpname.c_str());
+            remove(tmpname.c_str());
         }
 
         return rc;
diff --git a/src/image.hpp b/src/image.hpp
index 5120ebc..e633c0b 100644
--- a/src/image.hpp
+++ b/src/image.hpp
@@ -21,7 +21,7 @@
 /*!
   @file    image.hpp
   @brief   Class JpegImage to access JPEG images
-  @version $Name:  $ $Revision: 1.10 $
+  @version $Name:  $ $Revision: 1.11 $
   @author  Andreas Huggel (ahu)
            <a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
   @date    09-Jan-04, ahu: created
@@ -118,15 +118,6 @@ namespace Exif {
          */
         virtual int eraseExifData(const std::string& path) const =0;
         /*!
-          @brief Erase the %Exif data from the image provided in the input
-                 stream is and write the result to file path.
-          @param path Path to the file.
-          @param is Input stream with the image to erase the %Exif data from.
-          @return 0 if successful.
-         */
-        virtual int eraseExifData(const std::string& path, 
-                                  std::istream& is) const =0;
-        /*!
           @brief Read from the image input stream is, erase %Exif data from the
                  image, if there is any, and write the resulting image to the
                  output stream os.
@@ -143,15 +134,6 @@ namespace Exif {
          */
         virtual int writeExifData(const std::string& path) const =0;
         /*!
-          @brief Add the %Exif data to the image provided in the input
-                 stream is and write the combined result to file path.
-          @param path Path to the file.
-          @param is Input stream with the image to add the %Exif data to.
-          @return 0 if successful.
-         */
-        virtual int writeExifData(const std::string& path, 
-                                  std::istream& is) const =0;
-        /*!
           @brief Read from the image input stream is, add %Exif data to the
                  image, replacing existing %Exif data, if there is any) and
                  write the resulting image to the output stream os.
@@ -333,23 +315,14 @@ namespace Exif {
           @param path Path to the file.
           @return 0 if successful;<br>
                  -1 if the input file cannot be opened;<br>
+                 -3 if the temporary file cannot be opened;<br>
+                 -4 if renaming the temporary file fails; or<br>
                  the return code of 
-                    eraseExifData(const std::string& path, std::istream& is) const
+                    eraseExifData(std::ostream& os, std::istream& is) const
                     if the call to this function fails.
          */
         int eraseExifData(const std::string& path) const;
         /*!
-          @brief Erase the %Exif data from the JPEG image provided in the input
-                 stream is and write the result to file path. If an %Exif APP1
-                 section exists in input stream, it is erased.
-          @param path Path to the file.
-          @param is Input stream with the JPEG image to erase the %Exif data from.
-          @return 0 if successful;<br>
-                 -3 if the temporary file cannot be opened;<br>
-                 -4 if renaming the temporary file fails.
-         */
-        int eraseExifData(const std::string& path, std::istream& is) const;
-        /*!
           @brief Erase %Exif data from the JPEG image is, write the resulting
                  image to the output stream os. If an %Exif APP1 section exists
                  in the input file, it is erased.
@@ -373,26 +346,13 @@ namespace Exif {
           @param path Path to the file.
           @return 0 if successful;<br>
                  -1 if the input file cannot be opened;<br>
-                 the return code of 
-                    writeExifData(const std::string& path, std::istream& is) const
-                    if the call to this function fails.
-         */
-        int writeExifData(const std::string& path) const;
-        /*!
-          @brief Add the %Exif data to the JPEG image provided in the input
-                 stream is and write the combined result to file path.  If an
-                 %Exif APP1 section exists in input stream, it is
-                 replaced. Otherwise, an %Exif data section is created.
-          @param path Path to the file.
-          @param is Input stream with the JPEG image to add the %Exif data to.
-          @return 0 if successful;<br>
                  -3 if the temporary file cannot be opened;<br>
                  -4 if renaming the temporary file fails; or<br>
                  the return code of 
                     writeExifData(std::ostream& os, std::istream& is) const
                     if the call to this function fails.
          */
-        int writeExifData(const std::string& path, std::istream& is) const;
+        int writeExifData(const std::string& path) const;
         /*!
           @brief Copy %Exif data into the JPEG image is, write the resulting
                  image to the output stream os. If an %Exif APP1 section exists

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list