nsxivb6a6c26
Moved thumbnail cache to ~/.sxiv/cache/
+8 −15
2 files changed
| @@ -308,7 +308,7 @@ Pan image left. | |||
| 308 | 308 | Pan image right. | |
| 309 | 309 | .SH THUMBNAIL CACHING | |
| 310 | 310 | To enable thumbnail caching, please make sure to create the directory | |
| 311 | − | .I ~/.sxiv/ | |
| 311 | + | .I ~/.sxiv/cache/ | |
| 312 | 312 | with write permissions. sxiv will then store all thumbnails inside this | |
| 313 | 313 | directory, but it will not create this directory by itself. It rather uses the | |
| 314 | 314 | 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 | |||
| 321 | 321 | to remove empty subdirectories: | |
| 322 | 322 | .P | |
| 323 | 323 | .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 | |
| 333 | 324 | find . \-depth \-type d \-empty ! \-name '.' \-exec rmdir {} \\; | |
| 334 | 325 | .RE | |
| 335 | 326 | .SH AUTHOR | |
| @@ -31,8 +31,10 @@ | |||
| 31 | 31 | #include "util.h" | |
| 32 | 32 | #include "config.h" | |
| 33 | 33 | ||
| 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; | |
| 36 | 38 | ||
| 37 | 39 | bool tns_cache_enabled(void) { | |
| 38 | 40 | struct stat stats; | |
| @@ -175,9 +177,9 @@ void tns_init(tns_t *tns, int cnt, win_t *win) { | |||
| 175 | 177 | if ((homedir = getenv("HOME")) != NULL) { | |
| 176 | 178 | if (cache_dir != NULL) | |
| 177 | 179 | 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); | |
| 181 | 183 | } else { | |
| 182 | 184 | warn("could not locate thumbnail cache directory"); | |
| 183 | 185 | } | |