Skip to content

Commit

Permalink
Don't try reading a file as an image if we're going to write it to th…
Browse files Browse the repository at this point in the history
…e SD card.
  • Loading branch information
David Betz authored and David Betz committed Jan 5, 2017
1 parent 11e229d commit 40ee527
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 40ee527

Please sign in to comment.