aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-10-24 11:14:01 +0200
committerBert Münnich <ber.t@posteo.de>2014-10-24 11:14:01 +0200
commit93e2a757d439b4965bf21b26a41628be9b2ec788 (patch)
treea781005cb53c6462f380f453c6affd70f46e0dc7
parente15dabde747c71dfcf49e4818099c4cc526c2d21 (diff)
Do not print could-not-open-warnings for files found by directory traversal
-rw-r--r--image.c5
-rw-r--r--main.c15
-rw-r--r--thumbs.c3
-rw-r--r--types.h2
4 files changed, 14 insertions, 11 deletions
diff --git a/image.c b/image.c
index d4093bf..ee9c30d 100644
--- a/image.c
+++ b/image.c
@@ -292,7 +292,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
DGifCloseFile(gif);
#endif
- if (err && !file->loaded)
+ if (err && file->warn)
warn("corrupted gif file: %s", file->name);
if (img->multi.cnt > 1) {
@@ -321,7 +321,8 @@ bool img_load(img_t *img, const fileinfo_t *file)
if (access(file->path, R_OK) < 0 ||
(img->im = imlib_load_image(file->path)) == NULL)
{
- warn("could not open image: %s", file->name);
+ if (file->warn)
+ warn("could not open image: %s", file->name);
return false;
}
diff --git a/main.c b/main.c
index 46d80aa..fcbab7d 100644
--- a/main.c
+++ b/main.c
@@ -113,7 +113,7 @@ void cleanup(void)
}
}
-void check_add_file(char *filename)
+void check_add_file(char *filename, bool given)
{
const char *bn;
@@ -121,7 +121,8 @@ void check_add_file(char *filename)
return;
if (access(filename, R_OK) < 0) {
- warn("could not open file: %s", filename);
+ if (given)
+ warn("could not open file: %s", filename);
return;
}
@@ -148,7 +149,7 @@ void check_add_file(char *filename)
}
#endif
- files[fileidx].loaded = false;
+ files[fileidx].warn = given;
files[fileidx].name = s_strdup(filename);
if (files[fileidx].path == NULL)
files[fileidx].path = files[fileidx].name;
@@ -332,7 +333,7 @@ void load_image(int new)
else if (new > 0 && new < fileidx)
new--;
}
- files[new].loaded = true;
+ files[new].warn = false;
fileidx = current = new;
info.open = false;
@@ -810,7 +811,7 @@ int main(int argc, char **argv)
while ((len = get_line(&filename, &n, stdin)) > 0) {
if (filename[len-1] == '\n')
filename[len-1] = '\0';
- check_add_file(filename);
+ check_add_file(filename, true);
}
free(filename);
}
@@ -823,7 +824,7 @@ int main(int argc, char **argv)
continue;
}
if (!S_ISDIR(fstats.st_mode)) {
- check_add_file(filename);
+ check_add_file(filename, true);
} else {
if (!options->recursive) {
warn("ignoring directory: %s", filename);
@@ -835,7 +836,7 @@ int main(int argc, char **argv)
}
start = fileidx;
while ((filename = r_readdir(&dir)) != NULL) {
- check_add_file(filename);
+ check_add_file(filename, false);
free((void*) filename);
}
r_closedir(&dir);
diff --git a/thumbs.c b/thumbs.c
index 8bdf6c6..5328d3a 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -323,7 +323,8 @@ bool tns_load(tns_t *tns, int n, bool force)
if (im == NULL && (access(file->path, R_OK) < 0 ||
(im = imlib_load_image(file->path)) == NULL))
{
- warn("could not open image: %s", file->name);
+ if (file->warn)
+ warn("could not open image: %s", file->name);
return false;
}
}
diff --git a/types.h b/types.h
index 5434588..78022bd 100644
--- a/types.h
+++ b/types.h
@@ -68,7 +68,7 @@ typedef struct {
const char *name; /* as given by user */
const char *path; /* always absolute */
const char *base;
- bool loaded;
+ bool warn;
bool marked;
} fileinfo_t;