Remove commented out code.
[geeqie.git] / src / ui_fileops.h
1 /*
2  * (SLIK) SimpLIstic sKin functions
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 - 2012 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef UI_FILEOPS_H
15 #define UI_FILEOPS_H
16
17
18 #include <sys/stat.h>
19 #include <sys/time.h>
20 #include <sys/types.h>
21 #include <time.h>
22
23
24
25 void print_term(const gchar *text_utf8);
26
27 #define printf_term(...) \
28         do { \
29                 gchar *msg = g_strdup_printf(__VA_ARGS__); \
30                 print_term(msg); \
31                 g_free(msg); \
32         } while (0)
33
34 #if GQ_DEBUG_PATH_UTF8
35 #define path_to_utf8(path) path_to_utf8_debug(path, __FILE__, __LINE__)
36 #define path_from_utf8(utf8) path_from_utf8_debug(utf8, __FILE__, __LINE__)
37 gchar *path_to_utf8_debug(const gchar *path, const gchar *file, gint line);
38 gchar *path_from_utf8_debug(const gchar *utf8, const gchar *file, gint line);
39 #else
40 gchar *path_to_utf8(const gchar *path);
41 gchar *path_from_utf8(const gchar *utf8);
42 #endif
43
44 const gchar *xdg_data_home_get(void);
45 const gchar *xdg_config_home_get(void);
46 const gchar *xdg_cache_home_get(void);
47 const gchar *homedir(void);
48 const gchar *get_rc_dir(void);
49 const gchar *get_collections_dir(void);
50 const gchar *get_trash_dir(void);
51
52 gboolean stat_utf8(const gchar *s, struct stat *st);
53 gboolean lstat_utf8(const gchar *s, struct stat *st);
54
55 gboolean isname(const gchar *s);
56 gboolean isfile(const gchar *s);
57 gboolean isdir(const gchar *s);
58 gboolean islink(const gchar *s);
59 gint64 filesize(const gchar *s);
60 time_t filetime(const gchar *s);
61 gboolean filetime_set(const gchar *s, time_t tval);
62 gboolean is_readable_file(const gchar *s);
63 gboolean access_file(const gchar *s, gint mode);
64 gboolean unlink_file(const gchar *s);
65 gboolean symlink_utf8(const gchar *source, const gchar *target);
66 gboolean mkdir_utf8(const gchar *s, gint mode);
67 gboolean rmdir_utf8(const gchar *s);
68 gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint mtime);
69 gboolean copy_file(const gchar *s, const gchar *t);
70 gboolean move_file(const gchar *s, const gchar *t);
71 gboolean rename_file(const gchar *s, const gchar *t);
72 gchar *get_current_dir(void);
73
74 /* return True on success, it is up to you to free
75  * the lists with string_list_free()
76  */
77 void string_list_free(GList *list);
78 GList *string_list_copy(const GList *list);
79
80 gchar *unique_filename(const gchar *path, const gchar *ext, const gchar *divider, gboolean pad);
81 gchar *unique_filename_simple(const gchar *path);
82
83 const gchar *filename_from_path(const gchar *path);
84 gchar *remove_level_from_path(const gchar *path);
85
86 const gchar *extension_from_path(const gchar *path);
87 gchar *remove_extension_from_path(const gchar *path);
88
89 gboolean file_extension_match(const gchar *path, const gchar *ext);
90
91 /* warning note: this modifies path string! */
92 void parse_out_relatives(gchar *path);
93
94 gboolean file_in_path(const gchar *name);
95
96 gboolean recursive_mkdir_if_not_exists(const gchar *path, mode_t mode);
97
98
99 /* generate md5 string from file,
100  * on failure returns newly allocated copy of error_text, error_text may be NULL
101   */
102 gchar *md5_text_from_file_utf8(const gchar *path, const gchar *error_text);
103 gboolean md5_get_digest_from_file_utf8(const gchar *path, guchar digest[16]);
104
105 #endif
106 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */