Check file exists and can be opened before continuing with run
authorMichael Welch <michaelgwelch@gmail.com>
Sat, 25 Feb 2012 22:33:07 +0000 (16:33 -0600)
committerMichael Welch <michaelgwelch@gmail.com>
Sat, 25 Feb 2012 22:33:07 +0000 (16:33 -0600)
csrc/brainmess.c

index a34f97c..6f9cd6c 100644 (file)
@@ -17,10 +17,12 @@ gchar getChar()
 int main(gint argc, gchar** args) 
 {
     if (argc != 2) exit(-1);
-    Tape* t = tape_new();
-
     FILE* file = fopen(args[1], "r");
+    if (file == NULL) exit(-2);
     
+    Tape* t = tape_new();
+
+
     GString* program_string = g_string_sized_new(200);
     const CHARS = 100;
     gchar* buffer = malloc(CHARS * sizeof(gchar));