2000-10-09 18:24:57 +02:00
|
|
|
/* gfileutils.h - File utility functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* GLib 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 version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GLib is distributed in the hope that it will be useful,
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with GLib; see the file COPYING.LIB. If not,
|
2014-01-23 12:58:29 +01:00
|
|
|
* see <http://www.gnu.org/licenses/>.
|
2000-10-09 18:24:57 +02:00
|
|
|
*/
|
|
|
|
|
2012-12-28 05:43:14 +01:00
|
|
|
#ifndef __G_FILEUTILS_H__
|
|
|
|
#define __G_FILEUTILS_H__
|
|
|
|
|
2011-10-12 06:24:46 +02:00
|
|
|
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
|
2008-03-14 20:30:38 +01:00
|
|
|
#error "Only <glib.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2001-06-26 18:01:21 +02: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 13:52:07 +02:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2000-10-09 18:24:57 +02: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 16:57:34 +02:00
|
|
|
G_FILE_ERROR_NOSYS,
|
2000-10-09 18:24:57 +02:00
|
|
|
G_FILE_ERROR_FAILED
|
|
|
|
} GFileError;
|
|
|
|
|
2011-10-17 07:30:31 +02:00
|
|
|
/* For backward-compat reasons, these are synced to an old
|
2000-10-09 18:24:57 +02: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 17:38:16 +01:00
|
|
|
G_FILE_TEST_EXISTS = 1 << 4
|
2000-10-09 18:24:57 +02:00
|
|
|
} GFileTest;
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 18:24:57 +02:00
|
|
|
GQuark g_file_error_quark (void);
|
|
|
|
/* So other code can generate a GFileError */
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 18:24:57 +02:00
|
|
|
GFileError g_file_error_from_errno (gint err_no);
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 18:24:57 +02:00
|
|
|
gboolean g_file_test (const gchar *filename,
|
|
|
|
GFileTest test);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2000-10-09 18:24:57 +02:00
|
|
|
gboolean g_file_get_contents (const gchar *filename,
|
|
|
|
gchar **contents,
|
2011-10-17 07:30:31 +02:00
|
|
|
gsize *length,
|
2000-10-09 18:24:57 +02:00
|
|
|
GError **error);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2005-05-05 16:57:29 +02:00
|
|
|
gboolean g_file_set_contents (const gchar *filename,
|
2011-10-17 07:30:31 +02:00
|
|
|
const gchar *contents,
|
|
|
|
gssize length,
|
|
|
|
GError **error);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2003-07-30 00:31:40 +02:00
|
|
|
gchar *g_file_read_link (const gchar *filename,
|
2011-10-17 07:30:31 +02:00
|
|
|
GError **error);
|
2000-10-09 18:24:57 +02:00
|
|
|
|
2011-08-14 20:09:58 +02:00
|
|
|
/* Wrapper / workalike for mkdtemp() */
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-08-14 20:09:58 +02:00
|
|
|
gchar *g_mkdtemp (gchar *tmpl);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-08-14 20:09:58 +02:00
|
|
|
gchar *g_mkdtemp_full (gchar *tmpl,
|
|
|
|
gint mode);
|
|
|
|
|
2000-10-30 23:06:22 +01:00
|
|
|
/* Wrapper / workalike for mkstemp() */
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gint g_mkstemp (gchar *tmpl);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gint g_mkstemp_full (gchar *tmpl,
|
|
|
|
gint flags,
|
|
|
|
gint mode);
|
2000-11-11 14:46:15 +01:00
|
|
|
|
2011-08-14 20:09:58 +02:00
|
|
|
/* Wrappers for g_mkstemp and g_mkdtemp() */
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gint g_file_open_tmp (const gchar *tmpl,
|
|
|
|
gchar **name_used,
|
|
|
|
GError **error);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_dir_make_tmp (const gchar *tmpl,
|
|
|
|
GError **error);
|
2000-10-09 18:24:57 +02:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_build_path (const gchar *separator,
|
|
|
|
const gchar *first_element,
|
|
|
|
...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_build_pathv (const gchar *separator,
|
|
|
|
gchar **args) G_GNUC_MALLOC;
|
2011-07-20 19:44:39 +02:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_build_filename (const gchar *first_element,
|
|
|
|
...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC;
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02: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_DIR_SEPARATOR '\\'
|
|
|
|
#define G_DIR_SEPARATOR_S "\\"
|
|
|
|
#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
|
|
|
|
#define G_SEARCHPATH_SEPARATOR ';'
|
|
|
|
#define G_SEARCHPATH_SEPARATOR_S ";"
|
|
|
|
|
|
|
|
#else /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
#define G_DIR_SEPARATOR '/'
|
|
|
|
#define G_DIR_SEPARATOR_S "/"
|
|
|
|
#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
|
|
|
|
#define G_SEARCHPATH_SEPARATOR ':'
|
|
|
|
#define G_SEARCHPATH_SEPARATOR_S ":"
|
|
|
|
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gboolean g_path_is_absolute (const gchar *file_name);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
const gchar *g_path_skip_root (const gchar *file_name);
|
2011-07-20 19:44:39 +02:00
|
|
|
|
2011-10-17 07:30:31 +02:00
|
|
|
GLIB_DEPRECATED_FOR(g_path_get_basename)
|
|
|
|
const gchar *g_basename (const gchar *file_name);
|
2011-11-03 05:04:15 +01:00
|
|
|
#ifndef G_DISABLE_DEPRECATED
|
2011-10-17 07:30:31 +02:00
|
|
|
#define g_dirname g_path_get_dirname
|
2011-11-03 05:04:15 +01:00
|
|
|
#endif
|
2011-10-17 07:30:31 +02:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_get_current_dir (void);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-10-17 07:30:31 +02:00
|
|
|
gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC;
|
2005-06-22 11:43:37 +02:00
|
|
|
|
2014-11-29 14:39:24 +01:00
|
|
|
#ifndef __GTK_DOC_IGNORE__
|
2012-11-16 00:18:54 +01:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#define g_file_test g_file_test_utf8
|
|
|
|
#define g_file_get_contents g_file_get_contents_utf8
|
|
|
|
#define g_mkstemp g_mkstemp_utf8
|
|
|
|
#define g_file_open_tmp g_file_open_tmp_utf8
|
|
|
|
#define g_get_current_dir g_get_current_dir_utf8
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2012-11-16 00:18:54 +01:00
|
|
|
gboolean g_file_test_utf8 (const gchar *filename,
|
|
|
|
GFileTest test);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2012-11-16 00:18:54 +01:00
|
|
|
gboolean g_file_get_contents_utf8 (const gchar *filename,
|
|
|
|
gchar **contents,
|
|
|
|
gsize *length,
|
|
|
|
GError **error);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2012-11-16 00:18:54 +01:00
|
|
|
gint g_mkstemp_utf8 (gchar *tmpl);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2012-11-16 00:18:54 +01:00
|
|
|
gint g_file_open_tmp_utf8 (const gchar *tmpl,
|
|
|
|
gchar **name_used,
|
|
|
|
GError **error);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2012-11-16 00:18:54 +01:00
|
|
|
gchar *g_get_current_dir_utf8 (void);
|
|
|
|
#endif /* G_OS_WIN32 */
|
2014-11-29 14:39:24 +01:00
|
|
|
#endif /* __GTK_DOC_IGNORE__ */
|
2012-11-16 00:18:54 +01: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 13:52:07 +02:00
|
|
|
G_END_DECLS
|
2000-10-09 18:24:57 +02: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 13:52:07 +02:00
|
|
|
#endif /* __G_FILEUTILS_H__ */
|