534a61e270c901545e5a5a77012e6178174bc3a1
[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  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __G_STDIO_H__
22 #define __G_STDIO_H__
23
24 #include <glib/gprintf.h>
25
26 #include <sys/stat.h>
27
28 #if defined(G_OS_UNIX) && !defined(G_STDIO_NO_WRAP_ON_UNIX)
29
30 /* Just pass on to the system functions, so there's no potential for data
31  * format mismatches, especially with large file interfaces.
32  */
33
34 #define g_open    open
35 #define g_rename  rename
36 #define g_mkdir   mkdir
37 #define g_stat    stat
38 #define g_lstat   lstat
39 #define g_unlink  unlink
40 #define g_remove  remove
41 #define g_rmdir   rmdir
42 #define g_fopen   fopen
43 #define g_freopen freopen
44
45 #else /* ! G_OS_UNIX */
46
47 /* Wrappers for C library functions that take pathname arguments. On
48  * Unix, the pathname is a file name as it literally is in the file
49  * system. On well-maintained systems with consistent users who know
50  * what they are doing and no exchange of files with others this would
51  * be a well-defined encoding, preferrably UTF-8. On Windows, the
52  * pathname is always in UTF-8, even if that is not the on-disk
53  * encoding, and not the encoding accepted by the C library or Win32
54  * API.
55  */
56
57 int g_open      (const gchar *filename,
58                  int          flags,
59                  int          mode);
60
61 int g_rename    (const gchar *oldfilename,
62                  const gchar *newfilename);
63
64 int g_mkdir     (const gchar *filename,
65                  int          mode);
66
67 int g_stat      (const gchar *filename,
68                  struct stat *buf);
69
70 int g_lstat     (const gchar *filename,
71                  struct stat *buf);
72
73 int g_unlink    (const gchar *filename);
74
75 int g_remove    (const gchar *filename);
76
77 int g_rmdir (const gchar *filename);
78
79 FILE *g_fopen   (const gchar *filename,
80                  const gchar *mode);
81
82 FILE *g_freopen (const gchar *filename,
83                  const gchar *mode,
84                  FILE        *stream);
85
86 #endif /* G_OS_UNIX */
87
88 #endif /* __G_STDIO_H__ */