glib/gstdio.h Add g_utime(). No need to include <sys/utime.h> in gstdio.h,
authorTor Lillqvist <tml@novell.com>
Thu, 29 May 2008 18:05:26 +0000 (18:05 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Thu, 29 May 2008 18:05:26 +0000 (18:05 +0000)
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.

svn path=/trunk/; revision=6960

ChangeLog
glib/glib.symbols
glib/gstdio.c
glib/gstdio.h

index 9f6147ec8893588cee34ad799e0faf4643df7cdf..f6c9cee601b25c4c6b750d3add2ce50f9d7aa6dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
 2008-05-29  Tor Lillqvist  <tml@novell.com>
 
        * glib/gnulib/printf-args.c (printf_fetchargs): wint_t is short on
index 257da5c563bc105f7bc02a2b9a83e964ed0cf3e4..57596863f6d86eaabd7ce4510f68b9c7428b7044 100644 (file)
@@ -1090,6 +1090,7 @@ g_access
 g_chdir
 g_unlink
 g_rmdir
+g_utime
 #endif
 #endif
 
index 4b7a611683d2c08e685dbd7769d9e52453ac1a80..09167a7ee3b384d0f85ce26cad6c1ea901b0c400 100644 (file)
@@ -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 @@ g_freopen (const gchar *filename,
 #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"
index dd9e82ad12a42e9d007ba15832b14ff9f5659845..f71a4e3cd3b9a8f7e828af5bc20b5de6488509b8 100644 (file)
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
 #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 @@ FILE *g_freopen (const gchar *filename,
                  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