From 40ee5270cd5b8a3201413fddb7baa0dcb91c4810 Mon Sep 17 00:00:00 2001 From: David Betz Date: Wed, 4 Jan 2017 20:58:48 -0500 Subject: [PATCH] Don't try reading a file as an image if we're going to write it to the SD card. --- src/main.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ab0dc11..a10ffc1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -276,27 +276,25 @@ int main(int argc, char *argv[]) } /* before we do anything else, make sure we can read the Propeller image file */ - if (file) { + if (file && !writeFile) { nmessage(INFO_OPENING_FILE, file); if (!(image = Loader::readFile(file, &imageSize))) { nmessage(ERROR_CANT_OPEN_FILE, file); return 1; } - if (!writeFile) { - switch (PropImage::validate(image, imageSize)) { - case PropImage::SUCCESS: - // success - break; - case PropImage::IMAGE_TRUNCATED: - nmessage(ERROR_FILE_TRUNCATED); - return 1; - case PropImage::IMAGE_CORRUPTED: - nmessage(ERROR_FILE_CORRUPTED); - return 1; - default: - nmessage(ERROR_INTERNAL_CODE_ERROR); - return 1; - } + switch (PropImage::validate(image, imageSize)) { + case PropImage::SUCCESS: + // success + break; + case PropImage::IMAGE_TRUNCATED: + nmessage(ERROR_FILE_TRUNCATED); + return 1; + case PropImage::IMAGE_CORRUPTED: + nmessage(ERROR_FILE_CORRUPTED); + return 1; + default: + nmessage(ERROR_INTERNAL_CODE_ERROR); + return 1; } }