Browse Source

add DUK_OPT_NO_FILE_IO and its DUK_USE_FILE_IO counterpart, make duk_push_string_file() sensitive to it

pull/1/head
Sami Vaarala 11 years ago
parent
commit
66331681a6
  1. 9
      src/duk_api.c
  2. 11
      src/duk_features.h

9
src/duk_api.c

@ -2289,6 +2289,7 @@ const char *duk_push_string(duk_context *ctx, const char *str) {
}
}
#ifdef DUK_USE_FILE_IO
/* This is a bit clunky because it is ANSI C portable. Should perhaps
* relocate to another file because this is potentially platform
* dependent.
@ -2333,6 +2334,14 @@ const char *duk_push_string_file(duk_context *ctx, const char *path) {
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "failed to read file");
return NULL;
}
#else
const char *duk_push_string_file(duk_context *ctx, const char *path) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT(ctx != NULL);
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "file I/O disabled");
return NULL;
}
#endif /* DUK_USE_FILE_IO */
void duk_push_pointer(duk_context *ctx, void *val) {
duk_tval tv;

11
src/duk_features.h

@ -971,6 +971,17 @@ extern double duk_computed_nan;
#define DUK_USE_DPRINT_COLORS
#endif
/*
* File I/O support. This is now used in a few API calls to e.g. push
* a string from file contents or eval a file. For portability it must
* be possible to disable I/O altogether.
*/
#undef DUK_USE_FILE_IO
#if !defined(DUK_OPT_NO_FILE_IO)
#define DUK_USE_FILE_IO
#endif
/*
* Profile processing
*

Loading…
Cancel
Save