imgviewer: handle no path arg; missing file

This commit is contained in:
K. Lange 2019-08-09 06:47:11 +09:00
parent 54ec34837b
commit 559ba18145
1 changed files with 9 additions and 3 deletions

View File

@ -128,6 +128,11 @@ int main(int argc, char * argv[]) {
}
}
if (optind >= argc) {
usage(argv);
return 1;
}
yctx = yutani_init();
if (!yctx) {
fprintf(stderr, "%s: failed to connect to compositor\n", argv[0]);
@ -145,12 +150,13 @@ int main(int argc, char * argv[]) {
decor_width = bounds.width;
decor_height = bounds.height;
int status;
if (strstr(argv[optind],".jpg")) {
load_sprite_jpg(&img, argv[optind]);
status = load_sprite_jpg(&img, argv[optind]);
} else {
load_sprite(&img, argv[optind]);
status = load_sprite(&img, argv[optind]);
}
if (!img.width) {
if (status) {
fprintf(stderr, "%s: failed to open image %s\n", argv[0], argv[optind]);
return 1;
}