Add some more cases to the app-id unit tests
[glib.git] / glib / gfileutils.h
blobfce5c50a6fa531cebed237ce6c7e89f8ef27eb9b
1 /* gfileutils.h - File utility functions
3 * Copyright 2000 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef __G_FILEUTILS_H__
20 #define __G_FILEUTILS_H__
22 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
23 #error "Only <glib.h> can be included directly."
24 #endif
26 #include <glib/gerror.h>
28 G_BEGIN_DECLS
30 #define G_FILE_ERROR g_file_error_quark ()
32 typedef enum
34 G_FILE_ERROR_EXIST,
35 G_FILE_ERROR_ISDIR,
36 G_FILE_ERROR_ACCES,
37 G_FILE_ERROR_NAMETOOLONG,
38 G_FILE_ERROR_NOENT,
39 G_FILE_ERROR_NOTDIR,
40 G_FILE_ERROR_NXIO,
41 G_FILE_ERROR_NODEV,
42 G_FILE_ERROR_ROFS,
43 G_FILE_ERROR_TXTBSY,
44 G_FILE_ERROR_FAULT,
45 G_FILE_ERROR_LOOP,
46 G_FILE_ERROR_NOSPC,
47 G_FILE_ERROR_NOMEM,
48 G_FILE_ERROR_MFILE,
49 G_FILE_ERROR_NFILE,
50 G_FILE_ERROR_BADF,
51 G_FILE_ERROR_INVAL,
52 G_FILE_ERROR_PIPE,
53 G_FILE_ERROR_AGAIN,
54 G_FILE_ERROR_INTR,
55 G_FILE_ERROR_IO,
56 G_FILE_ERROR_PERM,
57 G_FILE_ERROR_NOSYS,
58 G_FILE_ERROR_FAILED
59 } GFileError;
61 /* For backward-compat reasons, these are synced to an old
62 * anonymous enum in libgnome. But don't use that enum
63 * in new code.
65 typedef enum
67 G_FILE_TEST_IS_REGULAR = 1 << 0,
68 G_FILE_TEST_IS_SYMLINK = 1 << 1,
69 G_FILE_TEST_IS_DIR = 1 << 2,
70 G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
71 G_FILE_TEST_EXISTS = 1 << 4
72 } GFileTest;
74 GLIB_AVAILABLE_IN_ALL
75 GQuark g_file_error_quark (void);
76 /* So other code can generate a GFileError */
77 GLIB_AVAILABLE_IN_ALL
78 GFileError g_file_error_from_errno (gint err_no);
80 GLIB_AVAILABLE_IN_ALL
81 gboolean g_file_test (const gchar *filename,
82 GFileTest test);
83 GLIB_AVAILABLE_IN_ALL
84 gboolean g_file_get_contents (const gchar *filename,
85 gchar **contents,
86 gsize *length,
87 GError **error);
88 GLIB_AVAILABLE_IN_ALL
89 gboolean g_file_set_contents (const gchar *filename,
90 const gchar *contents,
91 gssize length,
92 GError **error);
93 GLIB_AVAILABLE_IN_ALL
94 gchar *g_file_read_link (const gchar *filename,
95 GError **error);
97 /* Wrapper / workalike for mkdtemp() */
98 GLIB_AVAILABLE_IN_2_30
99 gchar *g_mkdtemp (gchar *tmpl);
100 GLIB_AVAILABLE_IN_2_30
101 gchar *g_mkdtemp_full (gchar *tmpl,
102 gint mode);
104 /* Wrapper / workalike for mkstemp() */
105 GLIB_AVAILABLE_IN_ALL
106 gint g_mkstemp (gchar *tmpl);
107 GLIB_AVAILABLE_IN_ALL
108 gint g_mkstemp_full (gchar *tmpl,
109 gint flags,
110 gint mode);
112 /* Wrappers for g_mkstemp and g_mkdtemp() */
113 GLIB_AVAILABLE_IN_ALL
114 gint g_file_open_tmp (const gchar *tmpl,
115 gchar **name_used,
116 GError **error);
117 GLIB_AVAILABLE_IN_2_30
118 gchar *g_dir_make_tmp (const gchar *tmpl,
119 GError **error);
121 GLIB_AVAILABLE_IN_ALL
122 gchar *g_build_path (const gchar *separator,
123 const gchar *first_element,
124 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
125 GLIB_AVAILABLE_IN_ALL
126 gchar *g_build_pathv (const gchar *separator,
127 gchar **args) G_GNUC_MALLOC;
129 GLIB_AVAILABLE_IN_ALL
130 gchar *g_build_filename (const gchar *first_element,
131 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
132 GLIB_AVAILABLE_IN_ALL
133 gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC;
135 GLIB_AVAILABLE_IN_ALL
136 gint g_mkdir_with_parents (const gchar *pathname,
137 gint mode);
139 #ifdef G_OS_WIN32
141 /* On Win32, the canonical directory separator is the backslash, and
142 * the search path separator is the semicolon. Note that also the
143 * (forward) slash works as directory separator.
145 #define G_DIR_SEPARATOR '\\'
146 #define G_DIR_SEPARATOR_S "\\"
147 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
148 #define G_SEARCHPATH_SEPARATOR ';'
149 #define G_SEARCHPATH_SEPARATOR_S ";"
151 #else /* !G_OS_WIN32 */
153 #define G_DIR_SEPARATOR '/'
154 #define G_DIR_SEPARATOR_S "/"
155 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
156 #define G_SEARCHPATH_SEPARATOR ':'
157 #define G_SEARCHPATH_SEPARATOR_S ":"
159 #endif /* !G_OS_WIN32 */
161 GLIB_AVAILABLE_IN_ALL
162 gboolean g_path_is_absolute (const gchar *file_name);
163 GLIB_AVAILABLE_IN_ALL
164 const gchar *g_path_skip_root (const gchar *file_name);
166 GLIB_DEPRECATED_FOR(g_path_get_basename)
167 const gchar *g_basename (const gchar *file_name);
168 #ifndef G_DISABLE_DEPRECATED
169 #define g_dirname g_path_get_dirname
170 #endif
172 GLIB_AVAILABLE_IN_ALL
173 gchar *g_get_current_dir (void);
174 GLIB_AVAILABLE_IN_ALL
175 gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
176 GLIB_AVAILABLE_IN_ALL
177 gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC;
179 #ifndef __GTK_DOC_IGNORE__
180 #ifdef G_OS_WIN32
181 #define g_file_test g_file_test_utf8
182 #define g_file_get_contents g_file_get_contents_utf8
183 #define g_mkstemp g_mkstemp_utf8
184 #define g_file_open_tmp g_file_open_tmp_utf8
185 #define g_get_current_dir g_get_current_dir_utf8
187 GLIB_AVAILABLE_IN_ALL
188 gboolean g_file_test_utf8 (const gchar *filename,
189 GFileTest test);
190 GLIB_AVAILABLE_IN_ALL
191 gboolean g_file_get_contents_utf8 (const gchar *filename,
192 gchar **contents,
193 gsize *length,
194 GError **error);
195 GLIB_AVAILABLE_IN_ALL
196 gint g_mkstemp_utf8 (gchar *tmpl);
197 GLIB_AVAILABLE_IN_ALL
198 gint g_file_open_tmp_utf8 (const gchar *tmpl,
199 gchar **name_used,
200 GError **error);
201 GLIB_AVAILABLE_IN_ALL
202 gchar *g_get_current_dir_utf8 (void);
203 #endif /* G_OS_WIN32 */
204 #endif /* __GTK_DOC_IGNORE__ */
206 G_END_DECLS
208 #endif /* __G_FILEUTILS_H__ */