1 /*
2  * go-file.h :
3  *
4  * Copyright (C) 2004 Morten Welinder (terra@gnome.org)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301 USA.
20  */
21 #ifndef UT_GO_FILE_H
22 #define UT_GO_FILE_H
23 
24 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
25  * so even if it's commented out in-file that's still a lot of work for
26  * the preprocessor to do...
27  */
28 #ifndef UT_TYPES_H
29 #include "ut_types.h"
30 #endif
31 
32 #include <glib.h>
33 #include <gsf/gsf.h>
34 #include <time.h>
35 
36 G_BEGIN_DECLS
37 
38 typedef struct _UT_GOFilePermissions UT_GOFilePermissions;
39 
40 struct _UT_GOFilePermissions {
41 	gboolean owner_read;
42 	gboolean owner_write;
43 	gboolean owner_execute;
44 
45 	gboolean group_read;
46 	gboolean group_write;
47 	gboolean group_execute;
48 
49 	gboolean others_read;
50 	gboolean others_write;
51 	gboolean others_execute;
52 };
53 
54 typedef enum {
55 	UT_GO_DOTDOT_SYNTACTIC,    /* Assume no symlinks.  */
56 	UT_GO_DOTDOT_TEST,         /* Check.  */
57 	UT_GO_DOTDOT_LEAVE         /* Leave alone.  */
58 } UT_GODotDot;
59 
60 ABI_EXPORT gboolean UT_go_path_is_uri (const char * path);
61 ABI_EXPORT gboolean UT_go_path_is_path (const char * path);
62 
63 ABI_EXPORT char *UT_go_filename_simplify (const char *filename, UT_GODotDot dotdot, gboolean make_absolute);
64 ABI_EXPORT char *UT_go_url_simplify (const char *uri);
65 
66 ABI_EXPORT char *UT_go_filename_from_uri (const char *uri);
67 ABI_EXPORT char *UT_go_filename_to_uri (const char *filename);
68 
69 ABI_EXPORT char *UT_go_url_resolve_relative (const char *ref_uri, const char *rel_uri);
70 ABI_EXPORT char *UT_go_url_make_relative (const char *uri, const char *ref_uri);
71 
72 ABI_EXPORT char *UT_go_shell_arg_to_uri (const char *arg);
73 ABI_EXPORT char *UT_go_basename_from_uri (const char *uri);
74 ABI_EXPORT char *UT_go_dirname_from_uri (const char *uri, gboolean brief);
75 ABI_EXPORT gboolean UT_go_directory_create (char const *uri, int mode, GError **err);
76 ABI_EXPORT gchar const **UT_go_shell_argv_to_glib_encoding (gint argc, gchar const **argv);
77 ABI_EXPORT void UT_go_shell_argv_to_glib_encoding_free (void);
78 
79 ABI_EXPORT GsfInput  *UT_go_file_open		(char const *uri, GError **err);
80 ABI_EXPORT GsfOutput *UT_go_file_create	(char const *uri, GError **err);
81 ABI_EXPORT GSList *UT_go_file_split_urls	(char const *data);
82 
83 ABI_EXPORT gboolean UT_go_file_remove (char const *uri, GError **err);
84 
85 ABI_EXPORT gboolean UT_go_file_exists (char const *uri);
86 
87 ABI_EXPORT UT_GOFilePermissions *UT_go_get_file_permissions (char const *uri);
88 ABI_EXPORT void UT_go_set_file_permissions (char const *uri, UT_GOFilePermissions * file_permissions);
89 
90 ABI_EXPORT time_t UT_go_file_get_date_accessed (char const *uri);
91 ABI_EXPORT time_t UT_go_file_get_date_modified (char const *uri);
92 ABI_EXPORT time_t UT_go_file_get_date_changed  (char const *uri);
93 
94 ABI_EXPORT GError	*UT_go_url_show		(gchar const *url);
95 ABI_EXPORT gboolean UT_go_url_check_extension (gchar const *uri,
96 				 gchar const *std_ext,
97 				 gchar **new_uri);
98 ABI_EXPORT gchar	*UT_go_get_mime_type	(gchar const *uri);
99 ABI_EXPORT gchar	*UT_go_get_mime_type_for_data	(gconstpointer data, int data_size);
100 ABI_EXPORT gchar const	*UT_go_mime_type_get_description	(gchar const *mime_type);
101 
102 ABI_EXPORT const char * UT_go_guess_encoding (const char *raw, size_t len, const char *user_guess, char **utf8_str);
103 ABI_EXPORT char const * UT_go_get_real_name (void);
104 ABI_EXPORT gint UT_go_utf8_collate_casefold (const char *a, const char *b);
105 
106 G_END_DECLS
107 
108 #endif /* UT_GO_FILE_H */
109 //#endif
110 
111