gstdio.h

Go to the documentation of this file.
00001 /* gstdio.h - GFilename wrappers for C library functions
00002  *
00003  * Copyright 2004 Tor Lillqvist
00004  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00005  *
00006  * GLib is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * GLib is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with GLib; see the file COPYING.LIB.  If not,
00018  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef __G_STDIO_H__
00023 #define __G_STDIO_H__
00024 
00025 #include <_ansi.h>
00026 #include <glib/gprintf.h>
00027 
00028 #include <sys/stat.h>
00029 
00030 G_BEGIN_DECLS
00031 
00032 #if defined(G_OS_UNIX) && !defined(G_STDIO_NO_WRAP_ON_UNIX) && !defined(SYMBIAN)
00033 
00034 /* Just pass on to the system functions, so there's no potential for data
00035  * format mismatches, especially with large file interfaces. 
00036  * A few functions can't be handled in this way, since they are not defined
00037  * in a portable system header that we could include here.
00038  */
00039 
00040 #define g_chmod   chmod
00041 #define g_open    open
00042 #define g_creat   creat
00043 #define g_rename  rename
00044 #define g_mkdir   mkdir
00045 #define g_stat    stat
00046 #define g_lstat   lstat
00047 #define g_remove  remove
00048 #define g_fopen   fopen
00049 #define g_freopen freopen
00050 
00051 IMPORT_C int g_access (const gchar *filename,
00052               int          mode);
00053 
00054 IMPORT_C int g_chdir  (const gchar *path);
00055 
00056 IMPORT_C int g_unlink (const gchar *filename);
00057 
00058 IMPORT_C int g_rmdir  (const gchar *filename);
00059 
00060 #else /* ! G_OS_UNIX */
00061 
00062 /* Wrappers for C library functions that take pathname arguments. On
00063  * Unix, the pathname is a file name as it literally is in the file
00064  * system. On well-maintained systems with consistent users who know
00065  * what they are doing and no exchange of files with others this would
00066  * be a well-defined encoding, preferrably UTF-8. On Windows, the
00067  * pathname is always in UTF-8, even if that is not the on-disk
00068  * encoding, and not the encoding accepted by the C library or Win32
00069  * API.
00070  */
00071 
00072 IMPORT_C int g_access    (const gchar *filename,
00073                  int          mode);
00074 
00075 IMPORT_C int g_chmod     (const gchar *filename,
00076                  int          mode);
00077 
00078 IMPORT_C int g_open      (const gchar *filename,
00079                  int          flags,
00080                  int          mode);
00081 
00082 IMPORT_C int g_creat     (const gchar *filename,
00083                  int          mode);
00084 
00085 IMPORT_C int g_rename    (const gchar *oldfilename,
00086                  const gchar *newfilename);
00087 
00088 IMPORT_C int g_mkdir     (const gchar *filename,
00089                  int          mode);
00090 
00091 IMPORT_C int g_chdir     (const gchar *path);
00092 
00093 IMPORT_C int g_stat      (const gchar *filename,
00094                  struct stat *buf);
00095 
00096 IMPORT_C int g_lstat     (const gchar *filename,
00097                  struct stat *buf);
00098 
00099 IMPORT_C int g_unlink    (const gchar *filename);
00100 
00101 IMPORT_C int g_remove    (const gchar *filename);
00102 
00103 IMPORT_C int g_rmdir (const gchar *filename);
00104 
00105 IMPORT_C FILE *g_fopen   (const gchar *filename,
00106                  const gchar *mode);
00107 
00108 IMPORT_C FILE *g_freopen (const gchar *filename,
00109                  const gchar *mode,
00110                  FILE        *stream);
00111 
00112 #endif /* G_OS_UNIX */
00113 
00114 G_END_DECLS
00115 
00116 #endif /* __G_STDIO_H__ */

Copyright © Nokia Corporation 2001-2008
Back to top