- int touch(Pathname) added
authorJan Kupec <jkupec@suse.cz>
Wed, 15 Aug 2007 11:38:57 +0000 (11:38 +0000)
committerJan Kupec <jkupec@suse.cz>
Wed, 15 Aug 2007 11:38:57 +0000 (11:38 +0000)
zypp/PathInfo.cc
zypp/PathInfo.h

index 32adb17..4093dc0 100644 (file)
@@ -11,6 +11,7 @@
 */
 
 #include <sys/types.h> // for ::minor, ::major macros
+#include <utime.h>     // for ::utime
 #include <sys/statvfs.h>
 
 #include <iostream>
@@ -878,6 +879,23 @@ namespace zypp
       return mask;
     }
 
+    ///////////////////////////////////////////////////////////////////
+    //
+    //  METHOD NAME : touch
+    //  METHOD TYPE : int
+    //
+    int touch (const Pathname & path)
+    {
+      DBG << "touch " << path << std::endl;
+      struct ::utimbuf times;
+      times.actime = ::time( 0 );
+      times.modtime = ::time( 0 );
+      if ( ::utime( path.asString().c_str(), &times ) == -1 ) {
+        return _Log_Result( errno );
+      }
+      return _Log_Result( 0 );
+    }
+
     /////////////////////////////////////////////////////////////////
   } // namespace filesystem
   ///////////////////////////////////////////////////////////////////
index 35edfcf..33457cb 100644 (file)
@@ -659,6 +659,14 @@ namespace zypp
     { return mode_r & ~getUmask(); }
     //@}
 
+    /**
+     * Change file's modification and access times.
+     *
+     * \return 0 on success, errno on failure
+     * \see man utime
+     */
+    int touch (const Pathname & path);
+
     /////////////////////////////////////////////////////////////////
   } // namespace filesystem
   ///////////////////////////////////////////////////////////////////