Krolyxon
Commit b6a6c26

Branches

Refs →

nsxivb6a6c26

Moved thumbnail cache to ~/.sxiv/cache/

Author
Bert Münnich
Date
2013-01-08 20:55 +0100
Committer
Bert Münnich · 2013-01-12 23:40 +0100
Parent
d6a475e
Commit
b6a6c260e1876172c764c6eca3aae004026cd8aa

+8 −15

2 files changed

  1. M sxiv.1 +1 −10
  2. M thumbs.c +7 −5
M sxiv.1 View
@@ -308,7 +308,7 @@ Pan image left.
308308 Pan image right.
309309 .SH THUMBNAIL CACHING
310310 To enable thumbnail caching, please make sure to create the directory
311−.I ~/.sxiv/
311+.I ~/.sxiv/cache/
312312 with write permissions. sxiv will then store all thumbnails inside this
313313 directory, but it will not create this directory by itself. It rather uses the
314314 existance of this directory as an affirmation, that the user wants thumbnails
@@ -321,15 +321,6 @@ Additionally, run the following command afterwards inside the cache directory
321321 to remove empty subdirectories:
322322 .P
323323 .RS
324−find \-type d \-empty \-delete
325−.RE
326−.P
327−If the version of
328−.I find
329−installed on your local system does not support the \-delete option, then you
330−can also try the following command:
331−.P
332−.RS
333324 find . \-depth \-type d \-empty ! \-name '.' \-exec rmdir {} \\;
334325 .RE
335326 .SH AUTHOR
M thumbs.c View
@@ -31,8 +31,10 @@
3131 #include "util.h"
3232 #include "config.h"
3333
34−const int thumb_dim = THUMB_SIZE + 10;
35−char *cache_dir = NULL;
34+static const int thumb_dim = THUMB_SIZE + 10;
35+
36+static const char * const CACHE_DIR = ".sxiv/cache";
37+static char *cache_dir = NULL;
3638
3739 bool tns_cache_enabled(void) {
3840 struct stat stats;
@@ -175,9 +177,9 @@ void tns_init(tns_t *tns, int cnt, win_t *win) {
175177 if ((homedir = getenv("HOME")) != NULL) {
176178 if (cache_dir != NULL)
177179 free(cache_dir);
178− len = strlen(homedir) + 10;
179− cache_dir = (char*) s_malloc(len * sizeof(char));
180− snprintf(cache_dir, len, "%s/.sxiv", homedir);
180+ len = strlen(homedir) + strlen(CACHE_DIR) + 2;
181+ cache_dir = (char*) s_malloc(len);
182+ snprintf(cache_dir, len, "%s/%s", homedir, CACHE_DIR);
181183 } else {
182184 warn("could not locate thumbnail cache directory");
183185 }