mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[view] Added option "ui.sessions.postpone_unlink" . Refs #257
This option let clean files after exit of elinks, not immediately.
This commit is contained in:
parent
ce5cec35c5
commit
bd8b3f590c
@ -1569,6 +1569,11 @@ static union option_info config_options_info[] = {
|
||||
N_("Keep the session active even if the last terminal "
|
||||
"exits.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Postpone unlink temporary files"),
|
||||
"postpone_unlink", OPT_ZERO, 0,
|
||||
N_("Clean temporary files (created for example while viewing images) at exit "
|
||||
"of ELinks not immediately after preview.")),
|
||||
|
||||
INIT_OPT_STRING("ui", N_("Clipboard filename"),
|
||||
"clipboard_file", OPT_ZERO, "",
|
||||
N_("The filename of the clipboard. The 'copy-clipboard' action will append to it. "
|
||||
|
@ -324,6 +324,7 @@ terminate_all_subsystems(void)
|
||||
#ifdef CONFIG_COMBINE
|
||||
free_combined();
|
||||
#endif
|
||||
clean_temporary_files();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -50,9 +50,26 @@
|
||||
|
||||
|
||||
INIT_LIST_OF(struct terminal, terminals);
|
||||
INIT_LIST_OF(struct string_list_item, temporary_files);
|
||||
|
||||
static void check_if_no_terminal(void);
|
||||
|
||||
void
|
||||
clean_temporary_files(void)
|
||||
{
|
||||
struct string_list_item *tmp;
|
||||
|
||||
foreach (tmp, temporary_files) {
|
||||
struct string *str = &tmp->string;
|
||||
|
||||
if (str && str->source && *(str->source)) {
|
||||
unlink(str->source);
|
||||
/* fprintf(stderr, "clean: %s\n", str->source); */
|
||||
}
|
||||
}
|
||||
free_string_list(&temporary_files);
|
||||
}
|
||||
|
||||
void
|
||||
redraw_terminal(struct terminal *term)
|
||||
{
|
||||
@ -386,6 +403,8 @@ exec_on_terminal(struct terminal *term, const char *path,
|
||||
#endif
|
||||
|
||||
if (term->master) {
|
||||
size_t len;
|
||||
|
||||
if (!*path) {
|
||||
dispatch_special(delete_);
|
||||
return;
|
||||
@ -399,14 +418,28 @@ exec_on_terminal(struct terminal *term, const char *path,
|
||||
return;
|
||||
}
|
||||
|
||||
len = strlen(delete_);
|
||||
|
||||
if (len && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
||||
add_to_string_list(&temporary_files, delete_, len);
|
||||
len = 0;
|
||||
delete_ = "";
|
||||
}
|
||||
exec_on_master_terminal(term,
|
||||
path, strlen(path),
|
||||
delete_, strlen(delete_),
|
||||
delete_, len,
|
||||
fg);
|
||||
} else {
|
||||
size_t len = strlen(delete_);
|
||||
|
||||
if (len && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
||||
add_to_string_list(&temporary_files, delete_, len);
|
||||
len = 0;
|
||||
delete_ = "";
|
||||
}
|
||||
exec_on_slave_terminal( term,
|
||||
path, strlen(path),
|
||||
delete_, strlen(delete_),
|
||||
delete_, len,
|
||||
fg);
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,7 @@ void redraw_all_terminals(void);
|
||||
void destroy_all_terminals(void);
|
||||
void exec_thread(char *, int);
|
||||
void close_handle(void *);
|
||||
void clean_temporary_files(void);
|
||||
|
||||
#ifdef CONFIG_FASTMEM
|
||||
#define assert_terminal_ptr_not_dangling(suspect) ((void) 0)
|
||||
|
Loading…
Reference in New Issue
Block a user