summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-10-10 00:23:10 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-10-10 00:29:46 +0200
commit58e7ef40a6fc437f84b7761d2bf83acfc534ceb8 (patch)
tree57e60a788ce0e02413b80c00b09a6301fb738f51
parentb89a5f593d0a7739bb196be04af3d6c023f1b1d1 (diff)
filelist.c, imlib.c: Simplify opt.quiet handling
-rw-r--r--src/filelist.c62
-rw-r--r--src/imlib.c79
2 files changed, 61 insertions, 80 deletions
diff --git a/src/filelist.c b/src/filelist.c
index 050246e..6439b9d 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -157,29 +157,26 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)
errno = 0;
if (stat(path, &st)) {
- /* Display useful error message */
- switch (errno) {
- case ENOENT:
- case ENOTDIR:
- if (!opt.quiet)
+ if (!opt.quiet) {
+ switch (errno) {
+ case ENOENT:
+ case ENOTDIR:
weprintf("%s does not exist - skipping", path);
- break;
- case ELOOP:
- if (!opt.quiet)
+ break;
+ case ELOOP:
weprintf("%s - too many levels of symbolic links - skipping", path);
- break;
- case EACCES:
- if (!opt.quiet)
+ 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:
- if (!opt.quiet)
+ 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;
+ break;
+ }
}
free(path);
return;
@@ -300,25 +297,22 @@ int feh_file_info_load(feh_file * file, Imlib_Image im)
errno = 0;
if (stat(file->filename, &st)) {
- /* Display useful error message */
- switch (errno) {
- case ENOENT:
- case ENOTDIR:
- if (!opt.quiet)
+ if (!opt.quiet) {
+ switch (errno) {
+ case ENOENT:
+ case ENOTDIR:
weprintf("%s does not exist - skipping", file->filename);
- break;
- case ELOOP:
- if (!opt.quiet)
+ break;
+ case ELOOP:
weprintf("%s - too many levels of symbolic links - skipping", file->filename);
- break;
- case EACCES:
- if (!opt.quiet)
+ break;
+ case EACCES:
weprintf("you don't have permission to open %s - skipping", file->filename);
- break;
- default:
- if (!opt.quiet)
+ break;
+ default:
weprintf("couldn't open %s ", file->filename);
- break;
+ break;
+ }
}
return(1);
}
diff --git a/src/imlib.c b/src/imlib.c
index 443246d..ac7e667 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -169,65 +169,52 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
fputs("\n", stdout);
reset_output = 1;
}
- /* Check error code */
- switch (err) {
- case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
- if (!opt.quiet)
+ if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS)
+ eprintf("While loading %s - Out of file descriptors", file->filename);
+ else if (!opt.quiet) {
+ switch (err) {
+ case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
weprintf("%s - File does not exist", file->filename);
- break;
- case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
weprintf("%s - Directory specified for image filename", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
weprintf("%s - No read access to directory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_UNKNOWN:
- case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_UNKNOWN:
+ case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
weprintf("%s - No Imlib2 loader for that file format", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
weprintf("%s - Path specified is too long", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
weprintf("%s - Path component does not exist", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
weprintf("%s - Path component is not a directory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
weprintf("%s - Path points outside address space", file->filename);
- break;
- case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
weprintf("%s - Too many levels of symbolic links", file->filename);
- break;
- case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
weprintf("While loading %s - Out of memory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS:
- eprintf("While loading %s - Out of file descriptors", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
weprintf("%s - Cannot write to directory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
- if (!opt.quiet)
+ break;
+ case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
weprintf("%s - Cannot write - out of disk space", file->filename);
- break;
- default:
- if (!opt.quiet)
- weprintf("While loading %s - Unknown error (%d). Attempting to continue",
+ break;
+ default:
+ weprintf("While loading %s - Unknown error (%d)",
file->filename, err);
- break;
+ break;
+ }
}
D(("Load *failed*\n"));
return(0);