Commit 58e7ef40 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

filelist.c, imlib.c: Simplify opt.quiet handling

parent b89a5f59
Loading
Loading
Loading
Loading
+28 −34
Original line number Diff line number Diff line
@@ -157,19 +157,16 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)

	errno = 0;
	if (stat(path, &st)) {
		/* Display useful error message */
		if (!opt.quiet) {
			switch (errno) {
			case ENOENT:
			case ENOTDIR:
			if (!opt.quiet)
				weprintf("%s does not exist - skipping", path);
				break;
			case ELOOP:
			if (!opt.quiet)
				weprintf("%s - too many levels of symbolic links - skipping", path);
				break;
			case EACCES:
			if (!opt.quiet)
				weprintf("you don't have permission to open %s - skipping", path);
				break;
			case EOVERFLOW:
@@ -177,10 +174,10 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)
					"Recompile with stat64=1 to fix this");
				break;
			default:
			if (!opt.quiet)
				weprintf("couldn't open %s", path);
				break;
			}
		}
		free(path);
		return;
	}
@@ -300,26 +297,23 @@ int feh_file_info_load(feh_file * file, Imlib_Image im)

	errno = 0;
	if (stat(file->filename, &st)) {
		/* Display useful error message */
		if (!opt.quiet) {
			switch (errno) {
			case ENOENT:
			case ENOTDIR:
			if (!opt.quiet)
				weprintf("%s does not exist - skipping", file->filename);
				break;
			case ELOOP:
			if (!opt.quiet)
				weprintf("%s - too many levels of symbolic links - skipping", file->filename);
				break;
			case EACCES:
			if (!opt.quiet)
				weprintf("you don't have permission to open %s - skipping", file->filename);
				break;
			default:
			if (!opt.quiet)
				weprintf("couldn't open %s ", file->filename);
				break;
			}
		}
		return(1);
	}

+33 −46
Original line number Diff line number Diff line
@@ -169,66 +169,53 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
			fputs("\n", stdout);
			reset_output = 1;
		}
		/* Check error code */
		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:
			if (!opt.quiet)
				weprintf("%s - File does not exist", file->filename);
				break;
			case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
			if (!opt.quiet)
				weprintf("%s - Directory specified for image filename", file->filename);
				break;
			case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
			if (!opt.quiet)
				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)
				weprintf("%s - No Imlib2 loader for that file format", file->filename);
				break;
			case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
			if (!opt.quiet)
				weprintf("%s - Path specified is too long", file->filename);
				break;
			case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
			if (!opt.quiet)
				weprintf("%s - Path component does not exist", file->filename);
				break;
			case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
			if (!opt.quiet)
				weprintf("%s - Path component is not a directory", file->filename);
				break;
			case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
			if (!opt.quiet)
				weprintf("%s - Path points outside address space", file->filename);
				break;
			case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
			if (!opt.quiet)
				weprintf("%s - Too many levels of symbolic links", file->filename);
				break;
			case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
			if (!opt.quiet)
				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)
				weprintf("%s - Cannot write to directory", file->filename);
				break;
			case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
			if (!opt.quiet)
				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",
				weprintf("While loading %s - Unknown error (%d)",
						file->filename, err);
				break;
			}
		}
		D(("Load *failed*\n"));
		return(0);
	}