aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper Gutowski <klg@mmax.one.pl>2018-07-05 03:39:27 +0200
committerBert Münnich <ber.t@posteo.de>2018-07-30 10:28:35 +0200
commite6c9218319b82b875ffb0c15dd88f8f6e77c50e2 (patch)
treef510779fd20d4d7a1affbd9256e8faba46a93da2
parent1613b42411788810d73252ac86952b3e66c866ba (diff)
Don't skip dot files when cleaning cache
-rw-r--r--main.c2
-rw-r--r--sxiv.h2
-rw-r--r--thumbs.c2
-rw-r--r--util.c12
4 files changed, 12 insertions, 6 deletions
diff --git a/main.c b/main.c
index 1485246..5a13403 100644
--- a/main.c
+++ b/main.c
@@ -889,7 +889,7 @@ int main(int argc, char **argv)
continue;
}
start = fileidx;
- while ((filename = r_readdir(&dir)) != NULL) {
+ while ((filename = r_readdir(&dir, true)) != NULL) {
check_add_file(filename, false);
free((void*) filename);
}
diff --git a/sxiv.h b/sxiv.h
index d1acb4c..757674e 100644
--- a/sxiv.h
+++ b/sxiv.h
@@ -364,7 +364,7 @@ void error(int, int, const char*, ...);
void size_readable(float*, const char**);
int r_opendir(r_dir_t*, const char*, bool);
int r_closedir(r_dir_t*);
-char* r_readdir(r_dir_t*);
+char* r_readdir(r_dir_t*, bool);
int r_mkdir(char*);
diff --git a/thumbs.c b/thumbs.c
index 37be29f..b9320e7 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -131,7 +131,7 @@ void tns_clean_cache(tns_t *tns)
dirlen = strlen(cache_dir);
- while ((cfile = r_readdir(&dir)) != NULL) {
+ while ((cfile = r_readdir(&dir, false)) != NULL) {
filename = cfile + dirlen;
delete = false;
diff --git a/util.c b/util.c
index 8f41d78..b956fd7 100644
--- a/util.c
+++ b/util.c
@@ -134,7 +134,7 @@ int r_closedir(r_dir_t *rdir)
return ret;
}
-char* r_readdir(r_dir_t *rdir)
+char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
{
size_t len;
char *filename;
@@ -143,8 +143,14 @@ char* r_readdir(r_dir_t *rdir)
while (true) {
if (rdir->dir != NULL && (dentry = readdir(rdir->dir)) != NULL) {
- if (dentry->d_name[0] == '.')
- continue;
+ if (dentry->d_name[0] == '.') {
+ if (skip_dotfiles)
+ continue;
+ if (dentry->d_name[1] == '\0')
+ continue;
+ if (dentry->d_name[1] == '.' && dentry->d_name[2] == '\0')
+ continue;
+ }
len = strlen(rdir->name) + strlen(dentry->d_name) + 2;
filename = (char*) emalloc(len);