1 /* gfileutils.h - File utility functions
3 * Copyright 2000 Red Hat, Inc.
5 * GLib is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * GLib 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
16 * License along with GLib; see the file COPYING.LIB. If not,
17 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
22 #error "Only <glib.h> can be included directly."
25 #ifndef __G_FILEUTILS_H__
26 #define __G_FILEUTILS_H__
28 #include <glib/gerror.h>
32 #define G_FILE_ERROR g_file_error_quark ()
39 G_FILE_ERROR_NAMETOOLONG,
63 /* For backward-compat reasons, these are synced to an old
64 * anonymous enum in libgnome. But don't use that enum
69 G_FILE_TEST_IS_REGULAR = 1 << 0,
70 G_FILE_TEST_IS_SYMLINK = 1 << 1,
71 G_FILE_TEST_IS_DIR = 1 << 2,
72 G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
73 G_FILE_TEST_EXISTS = 1 << 4
76 GQuark g_file_error_quark (void);
77 /* So other code can generate a GFileError */
78 GFileError g_file_error_from_errno (gint err_no);
80 gboolean g_file_test (const gchar *filename,
82 gboolean g_file_get_contents (const gchar *filename,
86 gboolean g_file_set_contents (const gchar *filename,
87 const gchar *contents,
90 gchar *g_file_read_link (const gchar *filename,
93 /* Wrapper / workalike for mkdtemp() */
94 GLIB_AVAILABLE_IN_2_30
95 gchar *g_mkdtemp (gchar *tmpl);
96 GLIB_AVAILABLE_IN_2_30
97 gchar *g_mkdtemp_full (gchar *tmpl,
100 /* Wrapper / workalike for mkstemp() */
101 gint g_mkstemp (gchar *tmpl);
102 gint g_mkstemp_full (gchar *tmpl,
106 /* Wrappers for g_mkstemp and g_mkdtemp() */
107 gint g_file_open_tmp (const gchar *tmpl,
110 GLIB_AVAILABLE_IN_2_30
111 gchar *g_dir_make_tmp (const gchar *tmpl,
114 gchar *g_build_path (const gchar *separator,
115 const gchar *first_element,
116 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
117 gchar *g_build_pathv (const gchar *separator,
118 gchar **args) G_GNUC_MALLOC;
120 gchar *g_build_filename (const gchar *first_element,
121 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
122 gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC;
124 gint g_mkdir_with_parents (const gchar *pathname,
129 /* On Win32, the canonical directory separator is the backslash, and
130 * the search path separator is the semicolon. Note that also the
131 * (forward) slash works as directory separator.
133 #define G_DIR_SEPARATOR '\\'
134 #define G_DIR_SEPARATOR_S "\\"
135 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
136 #define G_SEARCHPATH_SEPARATOR ';'
137 #define G_SEARCHPATH_SEPARATOR_S ";"
139 #else /* !G_OS_WIN32 */
141 #define G_DIR_SEPARATOR '/'
142 #define G_DIR_SEPARATOR_S "/"
143 #define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
144 #define G_SEARCHPATH_SEPARATOR ':'
145 #define G_SEARCHPATH_SEPARATOR_S ":"
147 #endif /* !G_OS_WIN32 */
149 gboolean g_path_is_absolute (const gchar *file_name);
150 const gchar *g_path_skip_root (const gchar *file_name);
152 GLIB_DEPRECATED_FOR(g_path_get_basename)
153 const gchar *g_basename (const gchar *file_name);
154 #ifndef G_DISABLE_DEPRECATED
155 #define g_dirname g_path_get_dirname
158 gchar *g_get_current_dir (void);
159 gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
160 gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC;
164 #endif /* __G_FILEUTILS_H__ */