annotate src/ui_fileops.h @ 2916:ae6cdcd69d9f default tip

Merge with upstream/master.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 May 2019 11:46:50 +0300
parents 195267d1c78f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
1 /*
2350
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
2 * Copyright (C) 2004 John Ellis
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
3 * Copyright (C) 2008 - 2016 The Geeqie Team
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
4 *
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
5 * Author: John Ellis
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
6 *
2350
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
7 * This program is free software; you can redistribute it and/or modify
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
8 * it under the terms of the GNU General Public License as published by
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
10 * (at your option) any later version.
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
11 *
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
12 * This program is distributed in the hope that it will be useful,
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
15 * GNU General Public License for more details.
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
16 *
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
17 * You should have received a copy of the GNU General Public License along
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
18 * with this program; if not, write to the Free Software Foundation, Inc.,
95507e596256 Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents: 2254
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
20 */
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
21
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
22 #ifndef UI_FILEOPS_H
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
23 #define UI_FILEOPS_H
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
24
2254
0dfd0c2d7c38 fix include statements for large file support on 32-bit
Michael Schwendt <mschwendt@fedoraproject.org>
parents: 2021
diff changeset
25 #include "config.h"
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
26 #include <sys/stat.h>
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
27 #include <sys/time.h>
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
28 #include <sys/types.h>
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
29 #include <time.h>
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
30
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
31
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
32
2678
195267d1c78f Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents: 2454
diff changeset
33 void print_term(gboolean err, const gchar *text_utf8);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
34
2678
195267d1c78f Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents: 2454
diff changeset
35 #define printf_term(err, ...) \
403
5ec4bf3224c9 Introduce printf_term() macro and use it.
Laurent Monin <geeqie@norz.org>
parents: 319
diff changeset
36 do { \
5ec4bf3224c9 Introduce printf_term() macro and use it.
Laurent Monin <geeqie@norz.org>
parents: 319
diff changeset
37 gchar *msg = g_strdup_printf(__VA_ARGS__); \
2678
195267d1c78f Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents: 2454
diff changeset
38 print_term(err, msg); \
403
5ec4bf3224c9 Introduce printf_term() macro and use it.
Laurent Monin <geeqie@norz.org>
parents: 319
diff changeset
39 g_free(msg); \
442
f698b737556b Big whitespaces cleanup:
Laurent Monin <geeqie@norz.org>
parents: 403
diff changeset
40 } while (0)
403
5ec4bf3224c9 Introduce printf_term() macro and use it.
Laurent Monin <geeqie@norz.org>
parents: 319
diff changeset
41
1386
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
42 #if GQ_DEBUG_PATH_UTF8
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
43 #define path_to_utf8(path) path_to_utf8_debug(path, __FILE__, __LINE__)
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
44 #define path_from_utf8(utf8) path_from_utf8_debug(utf8, __FILE__, __LINE__)
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
45 gchar *path_to_utf8_debug(const gchar *path, const gchar *file, gint line);
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
46 gchar *path_from_utf8_debug(const gchar *utf8, const gchar *file, gint line);
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
47 #else
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
48 gchar *path_to_utf8(const gchar *path);
1386
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
49 gchar *path_from_utf8(const gchar *utf8);
e9c4c6247ae3 Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
Laurent Monin <geeqie@norz.org>
parents: 1360
diff changeset
50 #endif
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
51
1149
fc690206842a Implement preliminary support for XDG Base Directory Specification.
Laurent Monin <geeqie@norz.org>
parents: 1148
diff changeset
52 const gchar *xdg_data_home_get(void);
fc690206842a Implement preliminary support for XDG Base Directory Specification.
Laurent Monin <geeqie@norz.org>
parents: 1148
diff changeset
53 const gchar *xdg_config_home_get(void);
fc690206842a Implement preliminary support for XDG Base Directory Specification.
Laurent Monin <geeqie@norz.org>
parents: 1148
diff changeset
54 const gchar *xdg_cache_home_get(void);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
55 const gchar *homedir(void);
1145
94adf34fe826 Use functions to return directories instead of constants.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
56 const gchar *get_rc_dir(void);
94adf34fe826 Use functions to return directories instead of constants.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
57 const gchar *get_collections_dir(void);
94adf34fe826 Use functions to return directories instead of constants.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
58 const gchar *get_trash_dir(void);
94adf34fe826 Use functions to return directories instead of constants.
Laurent Monin <geeqie@norz.org>
parents: 1055
diff changeset
59
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
60 gboolean stat_utf8(const gchar *s, struct stat *st);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
61 gboolean lstat_utf8(const gchar *s, struct stat *st);
1229
2f11fec715ca sidecar files grouping was made case-insensitive
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 1164
diff changeset
62
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
63 gboolean isname(const gchar *s);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
64 gboolean isfile(const gchar *s);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
65 gboolean isdir(const gchar *s);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
66 gboolean islink(const gchar *s);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
67 gint64 filesize(const gchar *s);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
68 time_t filetime(const gchar *s);
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
69 gboolean filetime_set(const gchar *s, time_t tval);
1360
e6b453609ace Introduce is_readable_file() which test if file exists, is regular and readable.
Laurent Monin <geeqie@norz.org>
parents: 1284
diff changeset
70 gboolean is_readable_file(const gchar *s);
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
71 gboolean access_file(const gchar *s, gint mode);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
72 gboolean unlink_file(const gchar *s);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
73 gboolean symlink_utf8(const gchar *source, const gchar *target);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
74 gboolean mkdir_utf8(const gchar *s, gint mode);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
75 gboolean rmdir_utf8(const gchar *s);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
76 gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint mtime);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
77 gboolean copy_file(const gchar *s, const gchar *t);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
78 gboolean move_file(const gchar *s, const gchar *t);
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
79 gboolean rename_file(const gchar *s, const gchar *t);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
80 gchar *get_current_dir(void);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
81
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
82 /* return True on success, it is up to you to free
138
5be5d1c53016 replaced gchar* path with FileData *fd
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 112
diff changeset
83 * the lists with string_list_free()
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
84 */
138
5be5d1c53016 replaced gchar* path with FileData *fd
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 112
diff changeset
85 void string_list_free(GList *list);
1238
47e6d7aac05b simplified metadata interface, dropped metadata_read,
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 1229
diff changeset
86 GList *string_list_copy(const GList *list);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
87
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
88 gchar *unique_filename(const gchar *path, const gchar *ext, const gchar *divider, gboolean pad);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
89 gchar *unique_filename_simple(const gchar *path);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
90
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
91 const gchar *filename_from_path(const gchar *path);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
92 gchar *remove_level_from_path(const gchar *path);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
93
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
94 gchar *remove_extension_from_path(const gchar *path);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
95
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
96 gboolean file_extension_match(const gchar *path, const gchar *ext);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
97
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
98 /* warning note: this modifies path string! */
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
99 void parse_out_relatives(gchar *path);
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
100
1448
3e89d434d495 gint -> gboolean.
Laurent Monin <geeqie@norz.org>
parents: 1386
diff changeset
101 gboolean file_in_path(const gchar *name);
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
102
1164
78ad91b4ae61 Fix compilation warnings.
Laurent Monin <geeqie@norz.org>
parents: 1149
diff changeset
103 gboolean recursive_mkdir_if_not_exists(const gchar *path, mode_t mode);
1148
db3cdb2b9681 Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
Laurent Monin <geeqie@norz.org>
parents: 1145
diff changeset
104
1642
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
105
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
106 /* generate md5 string from file,
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
107 * on failure returns newly allocated copy of error_text, error_text may be NULL
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
108 */
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
109 gchar *md5_text_from_file_utf8(const gchar *path, const gchar *error_text);
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
110 gboolean md5_get_digest_from_file_utf8(const gchar *path, guchar digest[16]);
1e6188ed7a68 Fix up compilation using make -jN: sometimes it fails due to order of headers inclusion.
Laurent Monin <geeqie@norz.org>
parents: 1448
diff changeset
111
9
8d9e9edd6fdf Sync to GQview 1.5.9 release.
John Ellis <johne@verizon.net>
parents:
diff changeset
112 #endif
1055
4bbdfab3c89a Adding a vim modeline to all files - patch by Klaus Ethgen
Vladimir Nadvornik <nadvornik@suse.cz>
parents: 1000
diff changeset
113 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */