Krolyxon
Commit 93e2a75

Branches

Refs →

nsxiv93e2a75

Do not print could-not-open-warnings for files found by directory traversal

Author
Bert Münnich
Date
2014-10-24 11:14 +0200
Parent
e15dabd
Commit
93e2a757d439b4965bf21b26a41628be9b2ec788

+14 −11

4 files changed

  1. M image.c +3 −2
  2. M main.c +8 −7
  3. M thumbs.c +2 −1
  4. M types.h +1 −1
M image.c View
@@ -292,7 +292,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
292292 DGifCloseFile(gif);
293293 #endif
294294
295− if (err && !file->loaded)
295+ if (err && file->warn)
296296 warn("corrupted gif file: %s", file->name);
297297
298298 if (img->multi.cnt > 1) {
@@ -321,7 +321,8 @@ bool img_load(img_t *img, const fileinfo_t *file)
321321 if (access(file->path, R_OK) < 0 ||
322322 (img->im = imlib_load_image(file->path)) == NULL)
323323 {
324− warn("could not open image: %s", file->name);
324+ if (file->warn)
325+ warn("could not open image: %s", file->name);
325326 return false;
326327 }
327328
M main.c View
@@ -113,7 +113,7 @@ void cleanup(void)
113113 }
114114 }
115115
116−void check_add_file(char *filename)
116+void check_add_file(char *filename, bool given)
117117 {
118118 const char *bn;
119119
@@ -121,7 +121,8 @@ void check_add_file(char *filename)
121121 return;
122122
123123 if (access(filename, R_OK) < 0) {
124− warn("could not open file: %s", filename);
124+ if (given)
125+ warn("could not open file: %s", filename);
125126 return;
126127 }
127128
@@ -148,7 +149,7 @@ void check_add_file(char *filename)
148149 }
149150 #endif
150151
151− files[fileidx].loaded = false;
152+ files[fileidx].warn = given;
152153 files[fileidx].name = s_strdup(filename);
153154 if (files[fileidx].path == NULL)
154155 files[fileidx].path = files[fileidx].name;
@@ -332,7 +333,7 @@ void load_image(int new)
332333 else if (new > 0 && new < fileidx)
333334 new--;
334335 }
335− files[new].loaded = true;
336+ files[new].warn = false;
336337 fileidx = current = new;
337338
338339 info.open = false;
@@ -810,7 +811,7 @@ int main(int argc, char **argv)
810811 while ((len = get_line(&filename, &n, stdin)) > 0) {
811812 if (filename[len-1] == '\n')
812813 filename[len-1] = '\0';
813− check_add_file(filename);
814+ check_add_file(filename, true);
814815 }
815816 free(filename);
816817 }
@@ -823,7 +824,7 @@ int main(int argc, char **argv)
823824 continue;
824825 }
825826 if (!S_ISDIR(fstats.st_mode)) {
826− check_add_file(filename);
827+ check_add_file(filename, true);
827828 } else {
828829 if (!options->recursive) {
829830 warn("ignoring directory: %s", filename);
@@ -835,7 +836,7 @@ int main(int argc, char **argv)
835836 }
836837 start = fileidx;
837838 while ((filename = r_readdir(&dir)) != NULL) {
838− check_add_file(filename);
839+ check_add_file(filename, false);
839840 free((void*) filename);
840841 }
841842 r_closedir(&dir);
M thumbs.c View
@@ -323,7 +323,8 @@ bool tns_load(tns_t *tns, int n, bool force)
323323 if (im == NULL && (access(file->path, R_OK) < 0 ||
324324 (im = imlib_load_image(file->path)) == NULL))
325325 {
326− warn("could not open image: %s", file->name);
326+ if (file->warn)
327+ warn("could not open image: %s", file->name);
327328 return false;
328329 }
329330 }
M types.h View
@@ -68,7 +68,7 @@ typedef struct {
6868 const char *name; /* as given by user */
6969 const char *path; /* always absolute */
7070 const char *base;
71− bool loaded;
71+ bool warn;
7272 bool marked;
7373 } fileinfo_t;
7474