summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-08-11 18:16:29 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-08-11 18:16:29 +0200
commitab07fec91937b36fbc7728628b95c76a3cdb2c27 (patch)
treec800a54b4a7e8c1ef3fa66ee152009aedcabcccb /src/main.c
parent0e687beed3b293ea5495d8d62452256ec996159c (diff)
download0xFFFF-ab07fec91937b36fbc7728628b95c76a3cdb2c27.tar.bz2
main: Fix parse_image_arg, check if arg is file
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index ef947d5..d4f0dd3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -156,6 +156,7 @@ int verbose;
/* arg = [[[dev:[hw:]]ver:]type:]file[%%lay] */
static void parse_image_arg(char * arg, struct image_list ** image_first) {
+ struct stat st;
struct image * image;
char * file;
char * type;
@@ -165,6 +166,17 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) {
char * layout;
char * layout_file;
+ /* Fisrt check if arg is file, then try to parse arg format */
+ if ( stat(arg, &st) == 0 ) {
+ image = image_alloc_from_file(arg, NULL, NULL, NULL, NULL, NULL);
+ if ( ! image ) {
+ ERROR("Cannot load image file %s", file);
+ exit(1);
+ }
+ image_list_add(image_first, image);
+ return;
+ }
+
layout_file = strchr(arg, '%');
if (layout_file)
*(layout_file++) = 0;