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."
26 #include <glib/gerror.h>
30 #define G_FILE_ERROR g_file_error_quark ()
37 G_FILE_ERROR_NAMETOOLONG
,
61 /* For backward-compat reasons, these are synced to an old
62 * anonymous enum in libgnome. But don't use that 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
75 GQuark
g_file_error_quark (void);
76 /* So other code can generate a GFileError */
78 GFileError
g_file_error_from_errno (gint err_no
);
81 gboolean
g_file_test (const gchar
*filename
,
84 gboolean
g_file_get_contents (const gchar
*filename
,
89 gboolean
g_file_set_contents (const gchar
*filename
,
90 const gchar
*contents
,
94 gchar
*g_file_read_link (const gchar
*filename
,
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
,
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
,
112 /* Wrappers for g_mkstemp and g_mkdtemp() */
113 GLIB_AVAILABLE_IN_ALL
114 gint
g_file_open_tmp (const gchar
*tmpl
,
117 GLIB_AVAILABLE_IN_2_30
118 gchar
*g_dir_make_tmp (const gchar
*tmpl
,
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
,
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
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__
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
,
190 GLIB_AVAILABLE_IN_ALL
191 gboolean
g_file_get_contents_utf8 (const gchar
*filename
,
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
,
201 GLIB_AVAILABLE_IN_ALL
202 gchar
*g_get_current_dir_utf8 (void);
203 #endif /* G_OS_WIN32 */
204 #endif /* __GTK_DOC_IGNORE__ */
208 #endif /* __G_FILEUTILS_H__ */