main: fixed error handling when we can't read rom file
This commit is contained in:
parent
b1c9177460
commit
756d8a49d9
8
main.c
8
main.c
@ -23,6 +23,7 @@
|
|||||||
#include "simdata.h"
|
#include "simdata.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
void help(char* progname){
|
void help(char* progname){
|
||||||
printf("Usage: %s -i <file> \n", progname);
|
printf("Usage: %s -i <file> \n", progname);
|
||||||
@ -54,6 +55,13 @@ int main(int argc, char* argd[] ){
|
|||||||
|
|
||||||
/// READ ROM FILE ///
|
/// READ ROM FILE ///
|
||||||
FILE* rom=fopen(infile,"r");
|
FILE* rom=fopen(infile,"r");
|
||||||
|
|
||||||
|
if (rom == NULL) {
|
||||||
|
printf("ERROR: Couldn't open rom file\n");
|
||||||
|
perror(infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
fseek(rom, 0, SEEK_END);
|
fseek(rom, 0, SEEK_END);
|
||||||
if(ftell(rom)!=16777216){
|
if(ftell(rom)!=16777216){
|
||||||
printf("ERROR: ROM file isn't 16MiB\n");
|
printf("ERROR: ROM file isn't 16MiB\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user