diff options
author | Daniel Friesel <derf@finalrewind.org> | 2012-01-27 16:29:03 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2012-01-27 16:29:03 +0100 |
commit | f32e4f8b3876b5cf063b92fa8988a7bda3672795 (patch) | |
tree | 1094a9f2003aa103887f99bc00bc4840ddb62060 /src | |
parent | 6423c1732e35b88135a740a3593f792d36941e28 (diff) |
filelist.c: refactor stat error checks
Diffstat (limited to 'src')
-rw-r--r-- | src/filelist.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/src/filelist.c b/src/filelist.c index 63b3f65..522f3cc 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -118,6 +118,33 @@ int file_selector_all(const struct dirent *unused __attribute__((unused))) return 1; } +static void feh_print_stat_error(char *path) +{ + if (opt.quiet) + return; + + switch (errno) { + case ENOENT: + case ENOTDIR: + weprintf("%s does not exist - skipping", path); + break; + case ELOOP: + weprintf("%s - too many levels of symbolic links - skipping", path); + break; + case EACCES: + weprintf("you don't have permission to open %s - skipping", path); + break; + case EOVERFLOW: + weprintf("Cannot open %s - EOVERFLOW.\n" + "Recompile with stat64=1 to fix this", path); + break; + default: + weprintf("couldn't open %s", path); + break; + } +} + + /* Recursive */ void add_file_to_filelist_recursively(char *origpath, unsigned char level) { @@ -157,27 +184,7 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level) errno = 0; if (stat(path, &st)) { - if (!opt.quiet) { - switch (errno) { - case ENOENT: - case ENOTDIR: - weprintf("%s does not exist - skipping", path); - break; - case ELOOP: - weprintf("%s - too many levels of symbolic links - skipping", path); - break; - case EACCES: - weprintf("you don't have permission to open %s - skipping", path); - break; - case EOVERFLOW: - weprintf("Cannot open %s - EOVERFLOW.\n" - "Recompile with stat64=1 to fix this"); - break; - default: - weprintf("couldn't open %s", path); - break; - } - } + feh_print_stat_error(path); free(path); return; } @@ -297,23 +304,7 @@ int feh_file_info_load(feh_file * file, Imlib_Image im) errno = 0; if (stat(file->filename, &st)) { - if (!opt.quiet) { - switch (errno) { - case ENOENT: - case ENOTDIR: - weprintf("%s does not exist - skipping", file->filename); - break; - case ELOOP: - weprintf("%s - too many levels of symbolic links - skipping", file->filename); - break; - case EACCES: - weprintf("you don't have permission to open %s - skipping", file->filename); - break; - default: - weprintf("couldn't open %s ", file->filename); - break; - } - } + feh_print_stat_error(file->filename); return(1); } |