Newer
Older
int feh_thumbnail_setup_thumbnail_dir(void)
{
int status = 0;
struct stat sb;
char *dir, *dir_thumbnails, *home;
home = getenv("HOME");
if (home != NULL) {
Birte Kristina Friesel
committed
dir = estrjoin("/", home, ".thumbnails", td.cache_dir, NULL);
if (!stat(dir, &sb)) {
if (S_ISDIR(sb.st_mode))
status = 1;
else
weprintf("%s should be a directory", dir);
} else {
dir_thumbnails = estrjoin("/", home, ".thumbnails", NULL);
if (stat(dir_thumbnails, &sb) != 0) {
if (mkdir(dir_thumbnails, 0700) == -1)
weprintf("unable to create %s directory", dir_thumbnails);
}
if (mkdir(dir, 0700) == -1)
weprintf("unable to create %s directory", dir);
else
status = 1;
}
}
return status;
}