gfileutils.h

Go to the documentation of this file.
00001 /* gfileutils.h - File utility functions
00002  *
00003  *  Copyright 2000 Red Hat, Inc.
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_FILEUTILS_H__
00023 #define __G_FILEUTILS_H__
00024 
00025 #include <_ansi.h>
00026 #include <glib/gerror.h>
00027 
00028 G_BEGIN_DECLS
00029 
00030 #define G_FILE_ERROR g_file_error_quark ()
00031 
00032 typedef enum
00033 {
00034   G_FILE_ERROR_EXIST,
00035   G_FILE_ERROR_ISDIR,
00036   G_FILE_ERROR_ACCES,
00037   G_FILE_ERROR_NAMETOOLONG,
00038   G_FILE_ERROR_NOENT,
00039   G_FILE_ERROR_NOTDIR,
00040   G_FILE_ERROR_NXIO,
00041   G_FILE_ERROR_NODEV,
00042   G_FILE_ERROR_ROFS,
00043   G_FILE_ERROR_TXTBSY,
00044   G_FILE_ERROR_FAULT,
00045   G_FILE_ERROR_LOOP,
00046   G_FILE_ERROR_NOSPC,
00047   G_FILE_ERROR_NOMEM,
00048   G_FILE_ERROR_MFILE,
00049   G_FILE_ERROR_NFILE,
00050   G_FILE_ERROR_BADF,
00051   G_FILE_ERROR_INVAL,
00052   G_FILE_ERROR_PIPE,
00053   G_FILE_ERROR_AGAIN,
00054   G_FILE_ERROR_INTR,
00055   G_FILE_ERROR_IO,
00056   G_FILE_ERROR_PERM,
00057   G_FILE_ERROR_NOSYS,
00058   G_FILE_ERROR_FAILED
00059 } GFileError;
00060 
00061 /* For backward-compat reasons, these are synced to an old 
00062  * anonymous enum in libgnome. But don't use that enum
00063  * in new code.
00064  */
00065 typedef enum
00066 {
00067   G_FILE_TEST_IS_REGULAR    = 1 << 0,
00068   G_FILE_TEST_IS_SYMLINK    = 1 << 1,
00069   G_FILE_TEST_IS_DIR        = 1 << 2,
00070   G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
00071   G_FILE_TEST_EXISTS        = 1 << 4
00072 } GFileTest;
00073 
00074 IMPORT_C GQuark     g_file_error_quark      (void);
00075 /* So other code can generate a GFileError */
00076 IMPORT_C GFileError g_file_error_from_errno (gint err_no);
00077 
00078 #ifdef G_OS_WIN32
00079 #define g_file_test g_file_test_utf8
00080 #define g_file_get_contents g_file_get_contents_utf8
00081 #define g_mkstemp g_mkstemp_utf8
00082 #define g_file_open_tmp g_file_open_tmp_utf8
00083 #endif
00084 
00085 IMPORT_C gboolean g_file_test         (const gchar  *filename,
00086                               GFileTest     test);
00087 IMPORT_C gboolean g_file_get_contents (const gchar  *filename,
00088                               gchar       **contents,
00089                               gsize        *length,    
00090                               GError      **error);
00091 IMPORT_C gboolean g_file_set_contents (const gchar *filename,
00092                               const gchar *contents,
00093                               gssize         length,
00094                               GError       **error);
00095 IMPORT_C gchar   *g_file_read_link    (const gchar  *filename,
00096                               GError      **error);
00097 
00098 /* Wrapper / workalike for mkstemp() */
00099 IMPORT_C gint    g_mkstemp            (gchar        *tmpl);
00100 
00101 /* Wrapper for g_mkstemp */
00102 IMPORT_C gint    g_file_open_tmp      (const gchar  *tmpl,
00103                               gchar       **name_used,
00104                               GError      **error);
00105 
00106 IMPORT_C gchar *g_build_path     (const gchar *separator,
00107                          const gchar *first_element,
00108                          ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
00109 IMPORT_C gchar *g_build_pathv    (const gchar  *separator,
00110                          gchar       **args) G_GNUC_MALLOC;
00111 
00112 IMPORT_C gchar *g_build_filename (const gchar *first_element,
00113                          ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
00114 IMPORT_C gchar *g_build_filenamev (gchar      **args) G_GNUC_MALLOC;
00115 
00116 IMPORT_C int    g_mkdir_with_parents (const gchar *pathname,
00117                              int          mode);
00118 
00119 G_END_DECLS
00120 
00121 #endif /* __G_FILEUTILS_H__ */

Copyright © Nokia Corporation 2001-2008
Back to top