2000-10-09 16:24:57 +00:00
|
|
|
/* gfileutils.h - File utility functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Red Hat, Inc.
|
|
|
|
*
|
2016-12-27 19:14:03 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2017-01-05 12:47:07 +01:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2000-10-09 16:24:57 +00:00
|
|
|
*
|
2016-12-27 19:14:03 +01:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2000-10-09 16:24:57 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
2016-12-27 19:14:03 +01:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2000-10-09 16:24:57 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-27 23:43:14 -05:00
|
|
|
#ifndef __G_FILEUTILS_H__
|
|
|
|
#define __G_FILEUTILS_H__
|
|
|
|
|
2011-10-12 00:24:46 -04:00
|
|
|
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
|
2008-03-14 19:30:38 +00:00
|
|
|
#error "Only <glib.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2015-10-29 08:53:00 +02:00
|
|
|
#include <glibconfig.h>
|
2001-06-26 16:01:21 +00:00
|
|
|
#include <glib/gerror.h>
|
Split glib.h into many header files mostly according to the resp.
2000-10-12 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, galloca.h, garray.h, gasyncqueue.h, gbacktrace.h,
gcache.h, gcompletion.h, gconvert.h, gdataset.h, gdate.h, ghash.h,
ghook.h, giochannel.h, glist.h , gmacros.h, gmain.h, gmem.h,
gmessages.h, gnode.h, gprimes.h, gquark.h, gqueue.h, grand.h,
grel.h, gscanner.h, gslist.h, gstrfuncs.h, gstring.h, gthread.h,
gthreadpool.h, gtimer.h, gtree.h, gtypes.h, gutils.h: Split glib.h
into many header files mostly according to the resp. *.c-files.
* gmacros.h: Added G_BEGIN_DECLS and G_END_DECLS to mean: 'in case
of C++: extern "C" { ... }' analogous to glibc __BEGIN_DECLS and
__END_DECLS.
* configure.in, gerror.h, gfileutils.h, gshell.h, gspawn.h,
gunicode.h, : Changed guard-macro names to something more
consistent.
* configure.in, *.h: Use G_BEGIN_DECLS and G_END_DECLS.
2000-10-12 11:52:07 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2000-10-09 16:24:57 +00:00
|
|
|
|
|
|
|
#define G_FILE_ERROR g_file_error_quark ()
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
G_FILE_ERROR_EXIST,
|
|
|
|
G_FILE_ERROR_ISDIR,
|
|
|
|
G_FILE_ERROR_ACCES,
|
|
|
|
G_FILE_ERROR_NAMETOOLONG,
|
|
|
|
G_FILE_ERROR_NOENT,
|
|
|
|
G_FILE_ERROR_NOTDIR,
|
|
|
|
G_FILE_ERROR_NXIO,
|
|
|
|
G_FILE_ERROR_NODEV,
|
|
|
|
G_FILE_ERROR_ROFS,
|
|
|
|
G_FILE_ERROR_TXTBSY,
|
|
|
|
G_FILE_ERROR_FAULT,
|
|
|
|
G_FILE_ERROR_LOOP,
|
|
|
|
G_FILE_ERROR_NOSPC,
|
|
|
|
G_FILE_ERROR_NOMEM,
|
|
|
|
G_FILE_ERROR_MFILE,
|
|
|
|
G_FILE_ERROR_NFILE,
|
|
|
|
G_FILE_ERROR_BADF,
|
|
|
|
G_FILE_ERROR_INVAL,
|
|
|
|
G_FILE_ERROR_PIPE,
|
|
|
|
G_FILE_ERROR_AGAIN,
|
|
|
|
G_FILE_ERROR_INTR,
|
|
|
|
G_FILE_ERROR_IO,
|
|
|
|
G_FILE_ERROR_PERM,
|
2004-08-27 14:57:34 +00:00
|
|
|
G_FILE_ERROR_NOSYS,
|
2000-10-09 16:24:57 +00:00
|
|
|
G_FILE_ERROR_FAILED
|
|
|
|
} GFileError;
|
|
|
|
|
2011-10-17 01:30:31 -04:00
|
|
|
/* For backward-compat reasons, these are synced to an old
|
2000-10-09 16:24:57 +00:00
|
|
|
* anonymous enum in libgnome. But don't use that enum
|
|
|
|
* in new code.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
G_FILE_TEST_IS_REGULAR = 1 << 0,
|
|
|
|
G_FILE_TEST_IS_SYMLINK = 1 << 1,
|
|
|
|
G_FILE_TEST_IS_DIR = 1 << 2,
|
|
|
|
G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
|
2000-11-05 16:38:16 +00:00
|
|
|
G_FILE_TEST_EXISTS = 1 << 4
|
2000-10-09 16:24:57 +00:00
|
|
|
} GFileTest;
|
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 16:24:57 +00:00
|
|
|
GQuark g_file_error_quark (void);
|
|
|
|
/* So other code can generate a GFileError */
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 16:24:57 +00:00
|
|
|
GFileError g_file_error_from_errno (gint err_no);
|
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 16:24:57 +00:00
|
|
|
gboolean g_file_test (const gchar *filename,
|
|
|
|
GFileTest test);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 16:24:57 +00:00
|
|
|
gboolean g_file_get_contents (const gchar *filename,
|
|
|
|
gchar **contents,
|
2011-10-17 01:30:31 -04:00
|
|
|
gsize *length,
|
2000-10-09 16:24:57 +00:00
|
|
|
GError **error);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2005-05-05 14:57:29 +00:00
|
|
|
gboolean g_file_set_contents (const gchar *filename,
|
2011-10-17 01:30:31 -04:00
|
|
|
const gchar *contents,
|
|
|
|
gssize length,
|
|
|
|
GError **error);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2003-07-29 22:31:40 +00:00
|
|
|
gchar *g_file_read_link (const gchar *filename,
|
2011-10-17 01:30:31 -04:00
|
|
|
GError **error);
|
2000-10-09 16:24:57 +00:00
|
|
|
|
2011-08-14 14:09:58 -04:00
|
|
|
/* Wrapper / workalike for mkdtemp() */
|
2012-05-25 08:42:50 -04:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-08-14 14:09:58 -04:00
|
|
|
gchar *g_mkdtemp (gchar *tmpl);
|
2012-05-25 08:42:50 -04:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-08-14 14:09:58 -04:00
|
|
|
gchar *g_mkdtemp_full (gchar *tmpl,
|
|
|
|
gint mode);
|
|
|
|
|
2000-10-30 22:06:22 +00:00
|
|
|
/* Wrapper / workalike for mkstemp() */
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gint g_mkstemp (gchar *tmpl);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gint g_mkstemp_full (gchar *tmpl,
|
|
|
|
gint flags,
|
|
|
|
gint mode);
|
2000-11-11 13:46:15 +00:00
|
|
|
|
2011-08-14 14:09:58 -04:00
|
|
|
/* Wrappers for g_mkstemp and g_mkdtemp() */
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gint g_file_open_tmp (const gchar *tmpl,
|
|
|
|
gchar **name_used,
|
|
|
|
GError **error);
|
2012-05-25 08:42:50 -04:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_dir_make_tmp (const gchar *tmpl,
|
|
|
|
GError **error);
|
2000-10-09 16:24:57 +00:00
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_build_path (const gchar *separator,
|
|
|
|
const gchar *first_element,
|
|
|
|
...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_build_pathv (const gchar *separator,
|
|
|
|
gchar **args) G_GNUC_MALLOC;
|
2011-07-20 19:44:39 +02:00
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_build_filename (const gchar *first_element,
|
|
|
|
...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC;
|
2017-11-06 12:02:40 -08:00
|
|
|
GLIB_AVAILABLE_IN_2_56
|
|
|
|
gchar *g_build_filename_valist (const gchar *first_element,
|
|
|
|
va_list *args) G_GNUC_MALLOC;
|
2011-10-17 01:30:31 -04:00
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gint g_mkdir_with_parents (const gchar *pathname,
|
|
|
|
gint mode);
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
/* On Win32, the canonical directory separator is the backslash, and
|
|
|
|
* the search path separator is the semicolon. Note that also the
|
|
|
|
* (forward) slash works as directory separator.
|
|
|
|
*/
|
|
|
|
#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
|
|
|
|
|
|
|
|
#else /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
|
|
|
|
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gboolean g_path_is_absolute (const gchar *file_name);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
const gchar *g_path_skip_root (const gchar *file_name);
|
2011-07-20 19:44:39 +02:00
|
|
|
|
2011-10-17 01:30:31 -04:00
|
|
|
GLIB_DEPRECATED_FOR(g_path_get_basename)
|
|
|
|
const gchar *g_basename (const gchar *file_name);
|
2011-11-03 00:04:15 -04:00
|
|
|
#ifndef G_DISABLE_DEPRECATED
|
2011-10-17 01:30:31 -04:00
|
|
|
#define g_dirname g_path_get_dirname
|
2011-11-03 00:04:15 -04:00
|
|
|
#endif
|
2011-10-17 01:30:31 -04:00
|
|
|
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_get_current_dir (void);
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
|
2012-12-06 14:04:59 -05:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 01:30:31 -04:00
|
|
|
gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC;
|
2005-06-22 09:43:37 +00:00
|
|
|
|
2018-04-27 12:44:30 -03:00
|
|
|
GLIB_AVAILABLE_IN_2_58
|
|
|
|
gchar *g_canonicalize_filename (const gchar *filename,
|
|
|
|
const gchar *relative_to) G_GNUC_MALLOC;
|
|
|
|
|
Split glib.h into many header files mostly according to the resp.
2000-10-12 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, galloca.h, garray.h, gasyncqueue.h, gbacktrace.h,
gcache.h, gcompletion.h, gconvert.h, gdataset.h, gdate.h, ghash.h,
ghook.h, giochannel.h, glist.h , gmacros.h, gmain.h, gmem.h,
gmessages.h, gnode.h, gprimes.h, gquark.h, gqueue.h, grand.h,
grel.h, gscanner.h, gslist.h, gstrfuncs.h, gstring.h, gthread.h,
gthreadpool.h, gtimer.h, gtree.h, gtypes.h, gutils.h: Split glib.h
into many header files mostly according to the resp. *.c-files.
* gmacros.h: Added G_BEGIN_DECLS and G_END_DECLS to mean: 'in case
of C++: extern "C" { ... }' analogous to glibc __BEGIN_DECLS and
__END_DECLS.
* configure.in, gerror.h, gfileutils.h, gshell.h, gspawn.h,
gunicode.h, : Changed guard-macro names to something more
consistent.
* configure.in, *.h: Use G_BEGIN_DECLS and G_END_DECLS.
2000-10-12 11:52:07 +00:00
|
|
|
G_END_DECLS
|
2000-10-09 16:24:57 +00:00
|
|
|
|
Split glib.h into many header files mostly according to the resp.
2000-10-12 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, galloca.h, garray.h, gasyncqueue.h, gbacktrace.h,
gcache.h, gcompletion.h, gconvert.h, gdataset.h, gdate.h, ghash.h,
ghook.h, giochannel.h, glist.h , gmacros.h, gmain.h, gmem.h,
gmessages.h, gnode.h, gprimes.h, gquark.h, gqueue.h, grand.h,
grel.h, gscanner.h, gslist.h, gstrfuncs.h, gstring.h, gthread.h,
gthreadpool.h, gtimer.h, gtree.h, gtypes.h, gutils.h: Split glib.h
into many header files mostly according to the resp. *.c-files.
* gmacros.h: Added G_BEGIN_DECLS and G_END_DECLS to mean: 'in case
of C++: extern "C" { ... }' analogous to glibc __BEGIN_DECLS and
__END_DECLS.
* configure.in, gerror.h, gfileutils.h, gshell.h, gspawn.h,
gunicode.h, : Changed guard-macro names to something more
consistent.
* configure.in, *.h: Use G_BEGIN_DECLS and G_END_DECLS.
2000-10-12 11:52:07 +00:00
|
|
|
#endif /* __G_FILEUTILS_H__ */
|