hook gvariant vectors up to kdbus
[platform/upstream/glib.git] / glib / gstdio.h
1 /* gstdio.h - GFilename wrappers for C library functions
2  *
3  * Copyright 2004 Tor Lillqvist
4  *
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.
9  *
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.
14  *
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  * see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __G_STDIO_H__
21 #define __G_STDIO_H__
22
23 #include <glib/gprintf.h>
24
25 #include <sys/stat.h>
26
27 G_BEGIN_DECLS
28
29 #if defined (_MSC_VER) && !defined(_WIN64)
30
31 /* Make it clear that we mean the struct with 32-bit st_size and
32  * 32-bit st_*time fields as that is how the 32-bit GLib DLL normally
33  * has been compiled. If you get a compiler warning when calling
34  * g_stat(), do take it seriously and make sure that the type of
35  * struct stat the code in GLib fills in matches the struct the type
36  * of struct stat you pass to g_stat(). To avoid hassle, to get file
37  * attributes just use the GIO API instead which doesn't use struct
38  * stat.
39  *
40  * Sure, it would be nicer to use a struct with 64-bit st_size and
41  * 64-bit st_*time fields, but changing that now would break ABI. And
42  * in MinGW, a plain "struct stat" is the one with 32-bit st_size and
43  * st_*time fields.
44  */
45
46 typedef struct _stat32 GStatBuf;
47
48 #else
49
50 typedef struct stat GStatBuf;
51
52 #endif
53
54 #if defined(G_OS_UNIX) && !defined(G_STDIO_NO_WRAP_ON_UNIX)
55
56 /* Just pass on to the system functions, so there's no potential for data
57  * format mismatches, especially with large file interfaces. 
58  * A few functions can't be handled in this way, since they are not defined
59  * in a portable system header that we could include here.
60  */
61
62 #ifndef __GTK_DOC_IGNORE__
63 #define g_chmod   chmod
64 #define g_open    open
65 #define g_creat   creat
66 #define g_rename  rename
67 #define g_mkdir   mkdir
68 #define g_stat    stat
69 #define g_lstat   lstat
70 #define g_remove  remove
71 #define g_fopen   fopen
72 #define g_freopen freopen
73 #define g_utime   utime
74 #endif
75
76 GLIB_AVAILABLE_IN_ALL
77 int g_access (const gchar *filename,
78               int          mode);
79
80 GLIB_AVAILABLE_IN_ALL
81 int g_chdir  (const gchar *path);
82
83 GLIB_AVAILABLE_IN_ALL
84 int g_unlink (const gchar *filename);
85
86 GLIB_AVAILABLE_IN_ALL
87 int g_rmdir  (const gchar *filename);
88
89 #else /* ! G_OS_UNIX */
90
91 /* Wrappers for C library functions that take pathname arguments. On
92  * Unix, the pathname is a file name as it literally is in the file
93  * system. On well-maintained systems with consistent users who know
94  * what they are doing and no exchange of files with others this would
95  * be a well-defined encoding, preferably UTF-8. On Windows, the
96  * pathname is always in UTF-8, even if that is not the on-disk
97  * encoding, and not the encoding accepted by the C library or Win32
98  * API.
99  */
100
101 GLIB_AVAILABLE_IN_ALL
102 int g_access    (const gchar *filename,
103                  int          mode);
104
105 GLIB_AVAILABLE_IN_ALL
106 int g_chmod     (const gchar *filename,
107                  int          mode);
108
109 GLIB_AVAILABLE_IN_ALL
110 int g_open      (const gchar *filename,
111                  int          flags,
112                  int          mode);
113
114 GLIB_AVAILABLE_IN_ALL
115 int g_creat     (const gchar *filename,
116                  int          mode);
117
118 GLIB_AVAILABLE_IN_ALL
119 int g_rename    (const gchar *oldfilename,
120                  const gchar *newfilename);
121
122 GLIB_AVAILABLE_IN_ALL
123 int g_mkdir     (const gchar *filename,
124                  int          mode);
125
126 GLIB_AVAILABLE_IN_ALL
127 int g_chdir     (const gchar *path);
128
129 GLIB_AVAILABLE_IN_ALL
130 int g_stat      (const gchar *filename,
131                  GStatBuf    *buf);
132
133 GLIB_AVAILABLE_IN_ALL
134 int g_lstat     (const gchar *filename,
135                  GStatBuf    *buf);
136
137 GLIB_AVAILABLE_IN_ALL
138 int g_unlink    (const gchar *filename);
139
140 GLIB_AVAILABLE_IN_ALL
141 int g_remove    (const gchar *filename);
142
143 GLIB_AVAILABLE_IN_ALL
144 int g_rmdir     (const gchar *filename);
145
146 GLIB_AVAILABLE_IN_ALL
147 FILE *g_fopen   (const gchar *filename,
148                  const gchar *mode);
149
150 GLIB_AVAILABLE_IN_ALL
151 FILE *g_freopen (const gchar *filename,
152                  const gchar *mode,
153                  FILE        *stream);
154
155 struct utimbuf;                 /* Don't need the real definition of struct utimbuf when just
156                                  * including this header.
157                                  */
158
159 GLIB_AVAILABLE_IN_ALL
160 int g_utime     (const gchar    *filename,
161                  struct utimbuf *utb);
162
163 #endif /* G_OS_UNIX */
164
165 GLIB_AVAILABLE_IN_2_36
166 gboolean g_close (gint       fd,
167                   GError   **error);
168
169 G_END_DECLS
170
171 #endif /* __G_STDIO_H__ */