glib r6960 - in trunk: . glib



Author: tml
Date: Thu May 29 18:05:26 2008
New Revision: 6960
URL: http://svn.gnome.org/viewvc/glib?rev=6960&view=rev

Log:
2008-05-29  Tor Lillqvist  <tml novell com>

	* glib/gstdio.h
	* glib/gstdio.c: Add g_utime(). No need to include <sys/utime.h>
	in gstdio.h, just use a forward struct declaration.

	* glib/glib.symbols: Add it.



Modified:
   trunk/ChangeLog
   trunk/glib/glib.symbols
   trunk/glib/gstdio.c
   trunk/glib/gstdio.h

Modified: trunk/glib/glib.symbols
==============================================================================
--- trunk/glib/glib.symbols	(original)
+++ trunk/glib/glib.symbols	Thu May 29 18:05:26 2008
@@ -1090,6 +1090,7 @@
 g_chdir
 g_unlink
 g_rmdir
+g_utime
 #endif
 #endif
 

Modified: trunk/glib/gstdio.c
==============================================================================
--- trunk/glib/gstdio.c	(original)
+++ trunk/glib/gstdio.c	Thu May 29 18:05:26 2008
@@ -38,6 +38,7 @@
 #include <wchar.h>
 #include <direct.h>
 #include <io.h>
+#include <sys/utime.h>
 #endif
 
 #include "gstdio.h"
@@ -725,5 +726,48 @@
 #endif
 }
 
+/**
+ * g_utime:
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
+ * @utb: a pointer to a struct utimbuf.
+ *
+ * A wrapper for the POSIX utime() function. The utime() function
+ * sets the access and modification timestamps of a file.
+ * 
+ * See your C library manual for more details about how utime() works
+ * on your system.
+ *
+ * Returns: 0 if the operation was successful, -1 if an error 
+ *    occurred
+ * 
+ * Since: 2.18
+ */
+int
+g_utime (const gchar    *filename,
+	 struct utimbuf *utb)
+{
+#ifdef G_OS_WIN32
+  wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+  int retval;
+  int save_errno;
+
+  if (wfilename == NULL)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  
+  retval = _wutime (wfilename, (struct _utimbuf*) utb);
+  save_errno = errno;
+
+  g_free (wfilename);
+
+  errno = save_errno;
+  return retval;
+#else
+  return utime (filename, utb);
+#endif
+}
+
 #define __G_STDIO_C__
 #include "galiasdef.c"

Modified: trunk/glib/gstdio.h
==============================================================================
--- trunk/glib/gstdio.h	(original)
+++ trunk/glib/gstdio.h	Thu May 29 18:05:26 2008
@@ -45,6 +45,7 @@
 #define g_remove  remove
 #define g_fopen   fopen
 #define g_freopen freopen
+#define g_utime   utime
 
 int g_access (const gchar *filename,
 	      int          mode);
@@ -107,6 +108,13 @@
                  const gchar *mode,
                  FILE        *stream);
 
+struct utimbuf;			/* Don't need the real definition of struct utimbuf when just
+				 * including this header.
+				 */
+
+int g_utime     (const gchar    *filename,
+		 struct utimbuf *utb);
+
 #endif /* G_OS_UNIX */
 
 G_END_DECLS



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