1 /* gstdio.h - GFilename wrappers for C library functions
3 * Copyright 2004 Tor Lillqvist
5 * GLib is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * GLib is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with GLib; see the file COPYING.LIB. If not,
17 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
24 #include <glib/gprintf.h>
30 #if defined(G_OS_UNIX) && !defined(G_STDIO_NO_WRAP_ON_UNIX)
32 /* Just pass on to the system functions, so there's no potential for data
33 * format mismatches, especially with large file interfaces.
34 * A few functions can't be handled in this way, since they are not defined
35 * in a portable system header that we could include here.
41 #define g_rename rename
45 #define g_remove remove
47 #define g_freopen freopen
50 int g_access (const gchar *filename,
53 int g_chdir (const gchar *path);
55 int g_unlink (const gchar *filename);
57 int g_rmdir (const gchar *filename);
59 #else /* ! G_OS_UNIX */
61 /* Wrappers for C library functions that take pathname arguments. On
62 * Unix, the pathname is a file name as it literally is in the file
63 * system. On well-maintained systems with consistent users who know
64 * what they are doing and no exchange of files with others this would
65 * be a well-defined encoding, preferrably UTF-8. On Windows, the
66 * pathname is always in UTF-8, even if that is not the on-disk
67 * encoding, and not the encoding accepted by the C library or Win32
71 int g_access (const gchar *filename,
74 int g_chmod (const gchar *filename,
77 int g_open (const gchar *filename,
81 int g_creat (const gchar *filename,
84 int g_rename (const gchar *oldfilename,
85 const gchar *newfilename);
87 int g_mkdir (const gchar *filename,
90 int g_chdir (const gchar *path);
94 /* The _g_stat_struct struct tag is an internal implementation detail
95 * and not part of the public GLib API.
98 #if defined (_MSC_VER) && !defined(_WIN64)
100 /* Make it clear that we mean the struct with 32-bit st_size and
101 * 32-bit st_*time fields as that is how the 32-bit GLib DLL normally
102 * has been compiled. If you get a compiler warning when calling
103 * g_stat(), do take it seriously and make sure that the type of
104 * struct stat the code in GLib fills in matches the struct the type
105 * of struct stat you pass to g_stat(). To avoid hassle, just use the
106 * GIO API instead which doesn't use struct stat to get file
109 #define _g_stat_struct _stat32
113 #define _g_stat_struct _stat
117 int g_stat (const gchar *filename,
118 struct _g_stat_struct *buf);
120 int g_lstat (const gchar *filename,
121 struct _g_stat_struct *buf);
125 /* No _g_stat_struct used on Unix */
127 int g_stat (const gchar *filename,
130 int g_lstat (const gchar *filename,
135 int g_unlink (const gchar *filename);
137 int g_remove (const gchar *filename);
139 int g_rmdir (const gchar *filename);
141 FILE *g_fopen (const gchar *filename,
144 FILE *g_freopen (const gchar *filename,
148 struct utimbuf; /* Don't need the real definition of struct utimbuf when just
149 * including this header.
152 int g_utime (const gchar *filename,
153 struct utimbuf *utb);
155 #endif /* G_OS_UNIX */
159 #endif /* __G_STDIO_H__ */