diff --git a/ssnes.c b/ssnes.c index 4fe7ff7930..197505c3a7 100644 --- a/ssnes.c +++ b/ssnes.c @@ -212,6 +212,14 @@ int main(int argc, char *argv[]) fprintf(stderr, "Usage: %s file\n", argv[0]); exit(1); } + + FILE *file = fopen(argv[1], "rb"); + if ( file == NULL ) + { + fprintf(stderr, "Could not open file: \"%s\"\n", argv[1]); + exit(1); + } + char savefile_name[strlen(argv[1]+5)]; strcpy(savefile_name, argv[1]); strcat(savefile_name, ".sav"); @@ -226,10 +234,6 @@ int main(int argc, char *argv[]) snes_set_input_state(input_state); - FILE *file = fopen(argv[1], "rb"); - if ( file == NULL ) - exit(1); - fseek(file, 0, SEEK_END); long length = ftell(file); rewind(file);