1 gfileutils.h |
1 /* gfileutils.h - File utility functions |
|
2 * |
|
3 * Copyright 2000 Red Hat, Inc. |
|
4 * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. |
|
5 * |
|
6 * GLib is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU Lesser General Public License as |
|
8 * published by the Free Software Foundation; either version 2 of the |
|
9 * License, or (at your option) any later version. |
|
10 * |
|
11 * GLib is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public |
|
17 * License along with GLib; see the file COPYING.LIB. If not, |
|
18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 * Boston, MA 02111-1307, USA. |
|
20 */ |
|
21 |
|
22 #ifndef __G_FILEUTILS_H__ |
|
23 #define __G_FILEUTILS_H__ |
|
24 |
|
25 #include <_ansi.h> |
|
26 #include <glib/gerror.h> |
|
27 |
|
28 G_BEGIN_DECLS |
|
29 |
|
30 #define G_FILE_ERROR g_file_error_quark () |
|
31 |
|
32 typedef enum |
|
33 { |
|
34 G_FILE_ERROR_EXIST, |
|
35 G_FILE_ERROR_ISDIR, |
|
36 G_FILE_ERROR_ACCES, |
|
37 G_FILE_ERROR_NAMETOOLONG, |
|
38 G_FILE_ERROR_NOENT, |
|
39 G_FILE_ERROR_NOTDIR, |
|
40 G_FILE_ERROR_NXIO, |
|
41 G_FILE_ERROR_NODEV, |
|
42 G_FILE_ERROR_ROFS, |
|
43 G_FILE_ERROR_TXTBSY, |
|
44 G_FILE_ERROR_FAULT, |
|
45 G_FILE_ERROR_LOOP, |
|
46 G_FILE_ERROR_NOSPC, |
|
47 G_FILE_ERROR_NOMEM, |
|
48 G_FILE_ERROR_MFILE, |
|
49 G_FILE_ERROR_NFILE, |
|
50 G_FILE_ERROR_BADF, |
|
51 G_FILE_ERROR_INVAL, |
|
52 G_FILE_ERROR_PIPE, |
|
53 G_FILE_ERROR_AGAIN, |
|
54 G_FILE_ERROR_INTR, |
|
55 G_FILE_ERROR_IO, |
|
56 G_FILE_ERROR_PERM, |
|
57 G_FILE_ERROR_NOSYS, |
|
58 G_FILE_ERROR_FAILED |
|
59 } GFileError; |
|
60 |
|
61 /* For backward-compat reasons, these are synced to an old |
|
62 * anonymous enum in libgnome. But don't use that enum |
|
63 * in new code. |
|
64 */ |
|
65 typedef enum |
|
66 { |
|
67 G_FILE_TEST_IS_REGULAR = 1 << 0, |
|
68 G_FILE_TEST_IS_SYMLINK = 1 << 1, |
|
69 G_FILE_TEST_IS_DIR = 1 << 2, |
|
70 G_FILE_TEST_IS_EXECUTABLE = 1 << 3, |
|
71 G_FILE_TEST_EXISTS = 1 << 4 |
|
72 } GFileTest; |
|
73 |
|
74 IMPORT_C GQuark g_file_error_quark (void); |
|
75 /* So other code can generate a GFileError */ |
|
76 IMPORT_C GFileError g_file_error_from_errno (gint err_no); |
|
77 |
|
78 #ifdef G_OS_WIN32 |
|
79 #define g_file_test g_file_test_utf8 |
|
80 #define g_file_get_contents g_file_get_contents_utf8 |
|
81 #define g_mkstemp g_mkstemp_utf8 |
|
82 #define g_file_open_tmp g_file_open_tmp_utf8 |
|
83 #endif |
|
84 |
|
85 IMPORT_C gboolean g_file_test (const gchar *filename, |
|
86 GFileTest test); |
|
87 IMPORT_C gboolean g_file_get_contents (const gchar *filename, |
|
88 gchar **contents, |
|
89 gsize *length, |
|
90 GError **error); |
|
91 IMPORT_C gboolean g_file_set_contents (const gchar *filename, |
|
92 const gchar *contents, |
|
93 gssize length, |
|
94 GError **error); |
|
95 IMPORT_C gchar *g_file_read_link (const gchar *filename, |
|
96 GError **error); |
|
97 |
|
98 /* Wrapper / workalike for mkstemp() */ |
|
99 IMPORT_C gint g_mkstemp (gchar *tmpl); |
|
100 |
|
101 /* Wrapper for g_mkstemp */ |
|
102 IMPORT_C gint g_file_open_tmp (const gchar *tmpl, |
|
103 gchar **name_used, |
|
104 GError **error); |
|
105 |
|
106 IMPORT_C gchar *g_build_path (const gchar *separator, |
|
107 const gchar *first_element, |
|
108 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; |
|
109 IMPORT_C gchar *g_build_pathv (const gchar *separator, |
|
110 gchar **args) G_GNUC_MALLOC; |
|
111 |
|
112 IMPORT_C gchar *g_build_filename (const gchar *first_element, |
|
113 ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; |
|
114 IMPORT_C gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; |
|
115 |
|
116 IMPORT_C int g_mkdir_with_parents (const gchar *pathname, |
|
117 int mode); |
|
118 |
|
119 G_END_DECLS |
|
120 |
|
121 #endif /* __G_FILEUTILS_H__ */ |