Skip to content
Browse files

load.c: Oops. Fixed compilation error made two commits ago.

  • Loading branch information...
1 parent 7af1033 commit a26fbfc16257fa42a3544e3ea809a90500e77292 @orangea orangea committed Dec 23, 2010
Showing with 8 additions and 2 deletions.
  1. +8 −2 core/load.c
View
10 core/load.c
@@ -16,7 +16,13 @@
void potion_load_code(Potion *P, const char *filename) {
PN buf, code;
- int fd = open(filename, O_RDONLY | O_BINARY);
+ struct stat stats;
+ int fd = -1;
+ if (stat(filename, &stats) == -1) {
+ fprintf(stderr, "** %s does not exist.", filename);
+ return;
+ }
+ fd = open(filename, O_RDONLY | O_BINARY);
if (fd == -1) {
fprintf(stderr, "** could not open %s. check permissions.", filename);
return;
@@ -27,7 +33,7 @@ void potion_load_code(Potion *P, const char *filename) {
code = potion_source_load(P, PN_NIL, buf);
if (!PN_IS_PROTO(code)) {
potion_run(P, potion_send(
- potion_parse(P, buf), PN_compile, potion_str(P, filename), PN_NIL), POTION_JIT);
+ potion_parse(P, buf), PN_compile, potion_str(P, filename), PN_NIL), POTION_JIT);
}
} else {
fprintf(stderr, "** could not read entire file: %s.", filename);

0 comments on commit a26fbfc

Please sign in to comment.
Something went wrong with that request. Please try again.