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.1 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 <glibconfig.h>
27 #include <glib/gerror.h>
31 #define G_FILE_ERROR g_file_error_quark ()
38 G_FILE_ERROR_NAMETOOLONG
,
62 /* For backward-compat reasons, these are synced to an old
63 * anonymous enum in libgnome. But don't use that enum
68 G_FILE_TEST_IS_REGULAR
= 1 << 0,
69 G_FILE_TEST_IS_SYMLINK
= 1 << 1,
70 G_FILE_TEST_IS_DIR
= 1 << 2,
71 G_FILE_TEST_IS_EXECUTABLE
= 1 << 3,
72 G_FILE_TEST_EXISTS
= 1 << 4
76 GQuark
g_file_error_quark (void);
77 /* So other code can generate a GFileError */
79 GFileError
g_file_error_from_errno (gint err_no
);
82 gboolean
g_file_test (const gchar
*filename
,
85 gboolean
g_file_get_contents (const gchar
*filename
,
90 gboolean
g_file_set_contents (const gchar
*filename
,
91 const gchar
*contents
,
95 gchar
*g_file_read_link (const gchar
*filename
,
98 /* Wrapper / workalike for mkdtemp() */
99 GLIB_AVAILABLE_IN_2_30
100 gchar
*g_mkdtemp (gchar
*tmpl
);
101 GLIB_AVAILABLE_IN_2_30
102 gchar
*g_mkdtemp_full (gchar
*tmpl
,
105 /* Wrapper / workalike for mkstemp() */
106 GLIB_AVAILABLE_IN_ALL
107 gint
g_mkstemp (gchar
*tmpl
);
108 GLIB_AVAILABLE_IN_ALL
109 gint
g_mkstemp_full (gchar
*tmpl
,
113 /* Wrappers for g_mkstemp and g_mkdtemp() */
114 GLIB_AVAILABLE_IN_ALL
115 gint
g_file_open_tmp (const gchar
*tmpl
,
118 GLIB_AVAILABLE_IN_2_30
119 gchar
*g_dir_make_tmp (const gchar
*tmpl
,
122 GLIB_AVAILABLE_IN_ALL
123 gchar
*g_build_path (const gchar
*separator
,
124 const gchar
*first_element
,
125 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED
;
126 GLIB_AVAILABLE_IN_ALL
127 gchar
*g_build_pathv (const gchar
*separator
,
128 gchar
**args
) G_GNUC_MALLOC
;
130 GLIB_AVAILABLE_IN_ALL
131 gchar
*g_build_filename (const gchar
*first_element
,
132 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED
;
133 GLIB_AVAILABLE_IN_ALL
134 gchar
*g_build_filenamev (gchar
**args
) G_GNUC_MALLOC
;
135 GLIB_AVAILABLE_IN_2_56
136 gchar
*g_build_filename_valist (const gchar
*first_element
,
137 va_list *args
) G_GNUC_MALLOC
;
139 GLIB_AVAILABLE_IN_ALL
140 gint
g_mkdir_with_parents (const gchar
*pathname
,
145 /* On Win32, the canonical directory separator is the backslash, and
146 * the search path separator is the semicolon. Note that also the
147 * (forward) slash works as directory separator.
149 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
151 #else /* !G_OS_WIN32 */
153 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
155 #endif /* !G_OS_WIN32 */
157 GLIB_AVAILABLE_IN_ALL
158 gboolean
g_path_is_absolute (const gchar
*file_name
);
159 GLIB_AVAILABLE_IN_ALL
160 const gchar
*g_path_skip_root (const gchar
*file_name
);
162 GLIB_DEPRECATED_FOR(g_path_get_basename
)
163 const gchar
*g_basename (const gchar
*file_name
);
164 #ifndef G_DISABLE_DEPRECATED
165 #define g_dirname g_path_get_dirname
168 GLIB_AVAILABLE_IN_ALL
169 gchar
*g_get_current_dir (void);
170 GLIB_AVAILABLE_IN_ALL
171 gchar
*g_path_get_basename (const gchar
*file_name
) G_GNUC_MALLOC
;
172 GLIB_AVAILABLE_IN_ALL
173 gchar
*g_path_get_dirname (const gchar
*file_name
) G_GNUC_MALLOC
;
175 GLIB_AVAILABLE_IN_2_58
176 gchar
*g_canonicalize_filename (const gchar
*filename
,
177 const gchar
*relative_to
) G_GNUC_MALLOC
;
181 #endif /* __G_FILEUTILS_H__ */