Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
gfileutils.h
Go to the documentation of this file.
1/* gfileutils.h - File utility functions
2 *
3 * Copyright 2000 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __G_FILEUTILS_H__
22#define __G_FILEUTILS_H__
23
24#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
25#error "Only <glib.h> can be included directly."
26#endif
27
28#include <glibconfig.h>
29#include <glib/gerror.h>
30
32
33#define G_FILE_ERROR g_file_error_quark ()
34
63
64/* For backward-compat reasons, these are synced to an old
65 * anonymous enum in libgnome. But don't use that enum
66 * in new code.
67 */
76
77/**
78 * GFileSetContentsFlags:
79 * @G_FILE_SET_CONTENTS_NONE: No guarantees about file consistency or durability.
80 * The most dangerous setting, which is slightly faster than other settings.
81 * @G_FILE_SET_CONTENTS_CONSISTENT: Guarantee file consistency: after a crash,
82 * either the old version of the file or the new version of the file will be
83 * available, but not a mixture. On Unix systems this equates to an `fsync()`
84 * on the file and use of an atomic `rename()` of the new version of the file
85 * over the old.
86 * @G_FILE_SET_CONTENTS_DURABLE: Guarantee file durability: after a crash, the
87 * new version of the file will be available. On Unix systems this equates to
88 * an `fsync()` on the file (if %G_FILE_SET_CONTENTS_CONSISTENT is unset), or
89 * the effects of %G_FILE_SET_CONTENTS_CONSISTENT plus an `fsync()` on the
90 * directory containing the file after calling `rename()`.
91 * @G_FILE_SET_CONTENTS_ONLY_EXISTING: Only apply consistency and durability
92 * guarantees if the file already exists. This may speed up file operations
93 * if the file doesn’t currently exist, but may result in a corrupted version
94 * of the new file if the system crashes while writing it.
95 *
96 * Flags to pass to g_file_set_contents_full() to affect its safety and
97 * performance.
98 *
99 * Since: 2.66
100 */
109
112/* So other code can generate a GFileError */
115
117gboolean g_file_test (const gchar *filename,
118 GFileTest test);
121 gchar **contents,
122 gsize *length,
123 GError **error);
126 const gchar *contents,
127 gssize length,
128 GError **error);
132 const gchar *contents,
133 gssize length,
135 int mode,
136 GError **error);
139gchar *g_file_read_link (const gchar *filename,
140 GError **error);
141
142/* Wrapper / workalike for mkdtemp() */
147 gint mode);
148
149/* Wrapper / workalike for mkstemp() */
154 gint flags,
155 gint mode);
156
157/* Wrappers for g_mkstemp and g_mkdtemp() */
160 gchar **name_used,
161 GError **error);
164 GError **error);
165
167gchar *g_build_path (const gchar *separator,
168 const gchar *first_element,
171gchar *g_build_pathv (const gchar *separator,
172 gchar **args) G_GNUC_MALLOC;
173
175gchar *g_build_filename (const gchar *first_element,
180gchar *g_build_filename_valist (const gchar *first_element,
181 va_list *args) G_GNUC_MALLOC;
182
185 gint mode);
186
187#ifdef G_OS_WIN32
188
189/* On Win32, the canonical directory separator is the backslash, and
190 * the search path separator is the semicolon. Note that also the
191 * (forward) slash works as directory separator.
192 */
193#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
194
195#else /* !G_OS_WIN32 */
196
197#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
198
199#endif /* !G_OS_WIN32 */
200
204const gchar *g_path_skip_root (const gchar *file_name);
205
207const gchar *g_basename (const gchar *file_name);
208#define g_dirname g_path_get_dirname GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_path_get_dirname)
209
216
219 const gchar *relative_to) G_GNUC_MALLOC;
220
222
223#endif /* __G_FILEUTILS_H__ */
GLIB_AVAILABLE_IN_ALL gchar * g_build_filenamev(gchar **args) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_2_30 gchar * g_dir_make_tmp(const gchar *tmpl, GError **error)
GFileError
Definition gfileutils.h:36
@ G_FILE_ERROR_FAULT
Definition gfileutils.h:47
@ G_FILE_ERROR_NOSYS
Definition gfileutils.h:60
@ G_FILE_ERROR_INVAL
Definition gfileutils.h:54
@ G_FILE_ERROR_ISDIR
Definition gfileutils.h:38
@ G_FILE_ERROR_NOTDIR
Definition gfileutils.h:42
@ G_FILE_ERROR_PIPE
Definition gfileutils.h:55
@ G_FILE_ERROR_EXIST
Definition gfileutils.h:37
@ G_FILE_ERROR_FAILED
Definition gfileutils.h:61
@ G_FILE_ERROR_MFILE
Definition gfileutils.h:51
@ G_FILE_ERROR_ROFS
Definition gfileutils.h:45
@ G_FILE_ERROR_NFILE
Definition gfileutils.h:52
@ G_FILE_ERROR_NOSPC
Definition gfileutils.h:49
@ G_FILE_ERROR_ACCES
Definition gfileutils.h:39
@ G_FILE_ERROR_NOMEM
Definition gfileutils.h:50
@ G_FILE_ERROR_TXTBSY
Definition gfileutils.h:46
@ G_FILE_ERROR_NODEV
Definition gfileutils.h:44
@ G_FILE_ERROR_IO
Definition gfileutils.h:58
@ G_FILE_ERROR_PERM
Definition gfileutils.h:59
@ G_FILE_ERROR_BADF
Definition gfileutils.h:53
@ G_FILE_ERROR_NAMETOOLONG
Definition gfileutils.h:40
@ G_FILE_ERROR_NOENT
Definition gfileutils.h:41
@ G_FILE_ERROR_NXIO
Definition gfileutils.h:43
@ G_FILE_ERROR_AGAIN
Definition gfileutils.h:56
@ G_FILE_ERROR_LOOP
Definition gfileutils.h:48
@ G_FILE_ERROR_INTR
Definition gfileutils.h:57
G_GNUC_END_IGNORE_DEPRECATIONS GLIB_AVAILABLE_IN_ALL gchar * g_file_read_link(const gchar *filename, GError **error)
GLIB_AVAILABLE_IN_ALL gboolean g_path_is_absolute(const gchar *file_name)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS GLIB_AVAILABLE_IN_2_66 gboolean g_file_set_contents_full(const gchar *filename, const gchar *contents, gssize length, GFileSetContentsFlags flags, int mode, GError **error)
GLIB_AVAILABLE_IN_2_30 gchar * g_mkdtemp(gchar *tmpl)
GLIB_AVAILABLE_IN_ALL gint g_mkdir_with_parents(const gchar *pathname, gint mode)
GLIB_AVAILABLE_IN_ALL gint g_file_open_tmp(const gchar *tmpl, gchar **name_used, GError **error)
GFileTest
Definition gfileutils.h:69
@ G_FILE_TEST_EXISTS
Definition gfileutils.h:74
@ G_FILE_TEST_IS_REGULAR
Definition gfileutils.h:70
@ G_FILE_TEST_IS_EXECUTABLE
Definition gfileutils.h:73
@ G_FILE_TEST_IS_SYMLINK
Definition gfileutils.h:71
@ G_FILE_TEST_IS_DIR
Definition gfileutils.h:72
GLIB_AVAILABLE_IN_2_56 gchar * g_build_filename_valist(const gchar *first_element, va_list *args) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_2_30 gchar * g_mkdtemp_full(gchar *tmpl, gint mode)
GLIB_AVAILABLE_IN_ALL gchar * g_build_path(const gchar *separator, const gchar *first_element,...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED
GLIB_AVAILABLE_IN_2_58 gchar * g_canonicalize_filename(const gchar *filename, const gchar *relative_to) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_ALL gchar * g_build_filename(const gchar *first_element,...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED
GLIB_AVAILABLE_IN_ALL GFileError g_file_error_from_errno(gint err_no)
GFileSetContentsFlags
Definition gfileutils.h:102
@ G_FILE_SET_CONTENTS_NONE
Definition gfileutils.h:103
@ G_FILE_SET_CONTENTS_ONLY_EXISTING
Definition gfileutils.h:106
@ G_FILE_SET_CONTENTS_CONSISTENT
Definition gfileutils.h:104
@ G_FILE_SET_CONTENTS_DURABLE
Definition gfileutils.h:105
const gchar * g_basename(const gchar *file_name)
GLIB_AVAILABLE_IN_ALL gboolean g_file_test(const gchar *filename, GFileTest test)
GLIB_AVAILABLE_IN_ALL gboolean g_file_get_contents(const gchar *filename, gchar **contents, gsize *length, GError **error)
GLIB_AVAILABLE_IN_ALL gchar * g_build_pathv(const gchar *separator, gchar **args) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_ALL gchar * g_get_current_dir(void)
GLIB_AVAILABLE_IN_ALL gboolean g_file_set_contents(const gchar *filename, const gchar *contents, gssize length, GError **error)
GLIB_AVAILABLE_IN_ALL GQuark g_file_error_quark(void)
GLIB_AVAILABLE_IN_ALL gchar * g_path_get_dirname(const gchar *file_name) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_ALL gchar * g_path_get_basename(const gchar *file_name) G_GNUC_MALLOC
GLIB_AVAILABLE_IN_ALL gint g_mkstemp_full(gchar *tmpl, gint flags, gint mode)
GLIB_AVAILABLE_IN_ALL gint g_mkstemp(gchar *tmpl)
GLIB_AVAILABLE_IN_ALL const gchar * g_path_skip_root(const gchar *file_name)
#define GLIB_DEPRECATED_FOR(f)
#define GLIB_AVAILABLE_IN_2_30
#define GLIB_AVAILABLE_IN_ALL
#define GLIB_AVAILABLE_IN_2_58
#define GLIB_AVAILABLE_ENUMERATOR_IN_2_66
#define GLIB_AVAILABLE_IN_2_56
#define GLIB_AVAILABLE_IN_2_66
signed long gssize
Definition glibconfig.h:82
unsigned long gsize
Definition glibconfig.h:83
#define G_GNUC_MALLOC
Definition gmacros.h:293
#define G_END_DECLS
Definition gmacros.h:910
#define G_GNUC_NULL_TERMINATED
Definition gmacros.h:326
#define G_BEGIN_DECLS
Definition gmacros.h:909
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Definition gmacros.h:771
#define G_GNUC_END_IGNORE_DEPRECATIONS
Definition gmacros.h:772
G_BEGIN_DECLS typedef guint32 GQuark
Definition gquark.h:38
gint gboolean
Definition gtypes.h:56
G_BEGIN_DECLS typedef char gchar
Definition gtypes.h:52
int gint
Definition gtypes.h:55
static void error(LoadState *S, const char *why)