diff options
author | Tor Lillqvist <tml@novell.com> | 2008-05-29 18:05:26 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2008-05-29 18:05:26 +0000 |
commit | 40c54c33ebecd9f1eb11b450201376c425f26a8b (patch) | |
tree | 0ac3c350d3e1e56ceb2c7669bb2cd6ada4b273f6 /glib/gstdio.c | |
parent | 3d65ed3d540b35f786685345b3d9f8b120283293 (diff) | |
download | glib-40c54c33ebecd9f1eb11b450201376c425f26a8b.tar.gz |
glib/gstdio.h Add g_utime(). No need to include <sys/utime.h> in gstdio.h,
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
Diffstat (limited to 'glib/gstdio.c')
-rw-r--r-- | glib/gstdio.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/glib/gstdio.c b/glib/gstdio.c index 4b7a61168..09167a7ee 100644 --- a/glib/gstdio.c +++ b/glib/gstdio.c @@ -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" |