Do not print could-not-open-warnings for files found by directory traversal
This commit is contained in:
parent
e15dabde74
commit
93e2a757d4
3
image.c
3
image.c
@ -292,7 +292,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
|
|||||||
DGifCloseFile(gif);
|
DGifCloseFile(gif);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (err && !file->loaded)
|
if (err && file->warn)
|
||||||
warn("corrupted gif file: %s", file->name);
|
warn("corrupted gif file: %s", file->name);
|
||||||
|
|
||||||
if (img->multi.cnt > 1) {
|
if (img->multi.cnt > 1) {
|
||||||
@ -321,6 +321,7 @@ bool img_load(img_t *img, const fileinfo_t *file)
|
|||||||
if (access(file->path, R_OK) < 0 ||
|
if (access(file->path, R_OK) < 0 ||
|
||||||
(img->im = imlib_load_image(file->path)) == NULL)
|
(img->im = imlib_load_image(file->path)) == NULL)
|
||||||
{
|
{
|
||||||
|
if (file->warn)
|
||||||
warn("could not open image: %s", file->name);
|
warn("could not open image: %s", file->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
13
main.c
13
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;
|
const char *bn;
|
||||||
|
|
||||||
@ -121,6 +121,7 @@ void check_add_file(char *filename)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (access(filename, R_OK) < 0) {
|
if (access(filename, R_OK) < 0) {
|
||||||
|
if (given)
|
||||||
warn("could not open file: %s", filename);
|
warn("could not open file: %s", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -148,7 +149,7 @@ void check_add_file(char *filename)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
files[fileidx].loaded = false;
|
files[fileidx].warn = given;
|
||||||
files[fileidx].name = s_strdup(filename);
|
files[fileidx].name = s_strdup(filename);
|
||||||
if (files[fileidx].path == NULL)
|
if (files[fileidx].path == NULL)
|
||||||
files[fileidx].path = files[fileidx].name;
|
files[fileidx].path = files[fileidx].name;
|
||||||
@ -332,7 +333,7 @@ void load_image(int new)
|
|||||||
else if (new > 0 && new < fileidx)
|
else if (new > 0 && new < fileidx)
|
||||||
new--;
|
new--;
|
||||||
}
|
}
|
||||||
files[new].loaded = true;
|
files[new].warn = false;
|
||||||
fileidx = current = new;
|
fileidx = current = new;
|
||||||
|
|
||||||
info.open = false;
|
info.open = false;
|
||||||
@ -810,7 +811,7 @@ int main(int argc, char **argv)
|
|||||||
while ((len = get_line(&filename, &n, stdin)) > 0) {
|
while ((len = get_line(&filename, &n, stdin)) > 0) {
|
||||||
if (filename[len-1] == '\n')
|
if (filename[len-1] == '\n')
|
||||||
filename[len-1] = '\0';
|
filename[len-1] = '\0';
|
||||||
check_add_file(filename);
|
check_add_file(filename, true);
|
||||||
}
|
}
|
||||||
free(filename);
|
free(filename);
|
||||||
}
|
}
|
||||||
@ -823,7 +824,7 @@ int main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!S_ISDIR(fstats.st_mode)) {
|
if (!S_ISDIR(fstats.st_mode)) {
|
||||||
check_add_file(filename);
|
check_add_file(filename, true);
|
||||||
} else {
|
} else {
|
||||||
if (!options->recursive) {
|
if (!options->recursive) {
|
||||||
warn("ignoring directory: %s", filename);
|
warn("ignoring directory: %s", filename);
|
||||||
@ -835,7 +836,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
start = fileidx;
|
start = fileidx;
|
||||||
while ((filename = r_readdir(&dir)) != NULL) {
|
while ((filename = r_readdir(&dir)) != NULL) {
|
||||||
check_add_file(filename);
|
check_add_file(filename, false);
|
||||||
free((void*) filename);
|
free((void*) filename);
|
||||||
}
|
}
|
||||||
r_closedir(&dir);
|
r_closedir(&dir);
|
||||||
|
1
thumbs.c
1
thumbs.c
@ -323,6 +323,7 @@ bool tns_load(tns_t *tns, int n, bool force)
|
|||||||
if (im == NULL && (access(file->path, R_OK) < 0 ||
|
if (im == NULL && (access(file->path, R_OK) < 0 ||
|
||||||
(im = imlib_load_image(file->path)) == NULL))
|
(im = imlib_load_image(file->path)) == NULL))
|
||||||
{
|
{
|
||||||
|
if (file->warn)
|
||||||
warn("could not open image: %s", file->name);
|
warn("could not open image: %s", file->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
2
types.h
2
types.h
@ -68,7 +68,7 @@ typedef struct {
|
|||||||
const char *name; /* as given by user */
|
const char *name; /* as given by user */
|
||||||
const char *path; /* always absolute */
|
const char *path; /* always absolute */
|
||||||
const char *base;
|
const char *base;
|
||||||
bool loaded;
|
bool warn;
|
||||||
bool marked;
|
bool marked;
|
||||||
} fileinfo_t;
|
} fileinfo_t;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user