Clean up g_thread_yield implementation
[platform/upstream/glib.git] / glib / gfileutils.h
1 /* gfileutils.h - File utility functions
2  *
3  *  Copyright 2000 Red Hat, Inc.
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 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
22 #error "Only <glib.h> can be included directly."
23 #endif
24
25 #ifndef __G_FILEUTILS_H__
26 #define __G_FILEUTILS_H__
27
28 #include <glib/gerror.h>
29
30 G_BEGIN_DECLS
31
32 #define G_FILE_ERROR g_file_error_quark ()
33
34 typedef enum
35 {
36   G_FILE_ERROR_EXIST,
37   G_FILE_ERROR_ISDIR,
38   G_FILE_ERROR_ACCES,
39   G_FILE_ERROR_NAMETOOLONG,
40   G_FILE_ERROR_NOENT,
41   G_FILE_ERROR_NOTDIR,
42   G_FILE_ERROR_NXIO,
43   G_FILE_ERROR_NODEV,
44   G_FILE_ERROR_ROFS,
45   G_FILE_ERROR_TXTBSY,
46   G_FILE_ERROR_FAULT,
47   G_FILE_ERROR_LOOP,
48   G_FILE_ERROR_NOSPC,
49   G_FILE_ERROR_NOMEM,
50   G_FILE_ERROR_MFILE,
51   G_FILE_ERROR_NFILE,
52   G_FILE_ERROR_BADF,
53   G_FILE_ERROR_INVAL,
54   G_FILE_ERROR_PIPE,
55   G_FILE_ERROR_AGAIN,
56   G_FILE_ERROR_INTR,
57   G_FILE_ERROR_IO,
58   G_FILE_ERROR_PERM,
59   G_FILE_ERROR_NOSYS,
60   G_FILE_ERROR_FAILED
61 } GFileError;
62
63 /* For backward-compat reasons, these are synced to an old 
64  * anonymous enum in libgnome. But don't use that enum
65  * in new code.
66  */
67 typedef enum
68 {
69   G_FILE_TEST_IS_REGULAR    = 1 << 0,
70   G_FILE_TEST_IS_SYMLINK    = 1 << 1,
71   G_FILE_TEST_IS_DIR        = 1 << 2,
72   G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
73   G_FILE_TEST_EXISTS        = 1 << 4
74 } GFileTest;
75
76 GQuark     g_file_error_quark      (void);
77 /* So other code can generate a GFileError */
78 GFileError g_file_error_from_errno (gint err_no);
79
80 #ifndef __GTK_DOC_IGNORE__
81 #ifdef G_OS_WIN32
82 #define g_file_test g_file_test_utf8
83 #define g_file_get_contents g_file_get_contents_utf8
84 #define g_mkstemp g_mkstemp_utf8
85 #define g_file_open_tmp g_file_open_tmp_utf8
86 #endif
87 #endif
88
89 gboolean g_file_test         (const gchar  *filename,
90                               GFileTest     test);
91 gboolean g_file_get_contents (const gchar  *filename,
92                               gchar       **contents,
93                               gsize        *length,    
94                               GError      **error);
95 gboolean g_file_set_contents (const gchar *filename,
96                               const gchar *contents,
97                               gssize         length,
98                               GError       **error);
99 gchar   *g_file_read_link    (const gchar  *filename,
100                               GError      **error);
101
102 /* Wrapper / workalike for mkdtemp() */
103 gchar   *g_mkdtemp            (gchar        *tmpl);
104 gchar   *g_mkdtemp_full       (gchar        *tmpl,
105                                gint          mode);
106
107 /* Wrapper / workalike for mkstemp() */
108 gint    g_mkstemp            (gchar        *tmpl);
109 gint    g_mkstemp_full       (gchar        *tmpl,
110                               gint          flags,
111                               gint          mode);
112
113 /* Wrappers for g_mkstemp and g_mkdtemp() */
114 gint    g_file_open_tmp      (const gchar  *tmpl,
115                               gchar       **name_used,
116                               GError      **error);
117 gchar  *g_dir_make_tmp       (const gchar  *tmpl,
118                               GError      **error);
119
120 typedef enum
121 {
122   G_FORMAT_SIZE_DEFAULT     = 0,
123   G_FORMAT_SIZE_LONG_FORMAT = 1 << 0,
124   G_FORMAT_SIZE_IEC_UNITS   = 1 << 1
125 } GFormatSizeFlags;
126
127 gchar * g_format_size_full   (guint64          size,
128                               GFormatSizeFlags flags);
129 gchar * g_format_size        (guint64          size);
130
131 #ifndef G_DISABLE_DEPRECATED
132 char *g_format_size_for_display (goffset size);
133 #endif
134
135 gchar *g_build_path     (const gchar *separator,
136                          const gchar *first_element,
137                          ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
138 gchar *g_build_pathv    (const gchar  *separator,
139                          gchar       **args) G_GNUC_MALLOC;
140
141 gchar *g_build_filename (const gchar *first_element,
142                          ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
143 gchar *g_build_filenamev (gchar      **args) G_GNUC_MALLOC;
144
145 int    g_mkdir_with_parents (const gchar *pathname,
146                              int          mode);
147
148 G_END_DECLS
149
150 #endif /* __G_FILEUTILS_H__ */