From bbbe4cdbc9ba9d43582c9420303d2aab977673a4 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 26 Jul 2026 14:23:21 +0200 Subject: hide #recovery# files from auto-completions, unless you already typed '#' * These files are created regularily and shouldn't be mangled with unless you're recovering from a crash. So it makes sense to hide them by default, just like the hidden .teco-* savepoint files. * Recovery file name creation and checks are now centralized in file-utils.h. --- src/file-utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/file-utils.h') diff --git a/src/file-utils.h b/src/file-utils.h index 11d6650..2b9003d 100644 --- a/src/file-utils.h +++ b/src/file-utils.h @@ -66,6 +66,22 @@ teco_file_normalize_path(gchar *path) gboolean teco_file_is_visible(const gchar *path); +static inline gboolean +teco_file_is_recovery(const gchar *path) +{ + g_autofree gchar *basename = g_path_get_basename(path); + gsize len = strlen(basename); + return len > 2 && basename[0] == '#' && basename[len-1] == '#'; +} + +static inline gchar * +teco_file_get_recovery(const gchar *path) +{ + g_autofree gchar *dirname = g_path_get_dirname(path); + g_autofree gchar *basename = g_path_get_basename(path); + return g_strconcat(dirname, G_DIR_SEPARATOR_S, "#", basename, "#", NULL); +} + /** * Get absolute path of the program executable. * -- cgit v1.2.3