[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Add a touch_file() function to compat so we can update cach...



Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv5508/src/common

Modified Files:
	compat.c compat.h 
Log Message:
Add a touch_file() function to compat so we can update cache mtimes.

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- compat.c	14 Sep 2005 20:59:25 -0000	1.67
+++ compat.c	14 Sep 2005 23:27:52 -0000	1.68
@@ -80,6 +80,12 @@
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+#ifdef HAVE_SYS_UTIME_H
+#include <sys/utime.h>
+#endif
 
 #include "log.h"
 #include "util.h"
@@ -269,6 +275,15 @@
 #endif
 }
 
+/** Change <b>fname</b>'s modification time to now. */
+int
+touch_file(const char *fname)
+{
+  if (utime(fname, NULL)!=0)
+    return -1;
+  return 0;
+}
+
 /** Turn <b>socket</b> into a nonblocking socket.
  */
 void

Index: compat.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- compat.h	10 Sep 2005 01:42:42 -0000	1.35
+++ compat.h	14 Sep 2005 23:27:52 -0000	1.36
@@ -127,6 +127,7 @@
 
 /* ===== File compatibility */
 int replace_file(const char *from, const char *to);
+int touch_file(const char *fname);
 
 #ifdef MS_WINDOWS
 #define PATH_SEPARATOR "\\"