2281
qlfLoad(char *file, Module *module ARG_LD)
2281
qlfLoad(IOSTREAM *fd, Module *module ARG_LD)
2284
const char *absloadname;
2286
2285
char tmp[MAXPATHLEN];
2287
2286
int saved_wsize;
2290
if ( !(absloadname = AbsoluteFile(wicFile, tmp)) )
2289
if ( (file = fileNameStream(fd)) )
2292
if ( !get_atom_text(file, &text) )
2294
if ( !PL_mb_text(&text, REP_FN) )
2295
{ PL_free_text(&text);
2298
wicFile = text.text.t;
2299
if ( !(absloadname = AbsoluteFile(wicFile, tmp)) )
2301
PL_free_text(&text);
2303
{ absloadname = NULL;
2293
if ( !(fd = Sopen_file(file, "rbr")) )
2294
{ term_t f = PL_new_term_ref();
2296
PL_put_atom_chars(f, file);
2297
return PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
2298
ATOM_open, ATOM_source_sink, f);
2300
2306
if ( !(lversion = qlfVersion(fd)) || lversion < LOADVERSION )
2303
2308
warning("$qlf_load/1: %s bad version (file version = %d, prolog = %d)",
2304
2309
wicFile, lversion, VERSION);
2480
pl_qlf_load(term_t file, term_t module)
2482
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2483
$qlf_load(:Stream, -ModuleOut)
2484
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2487
PRED_IMPL("$qlf_load", 2, qlf_load, PL_FA_TRANSPARENT)
2489
term_t qstream = A1;
2482
2491
Module m, oldsrc = LD->modules.source;
2485
term_t name = PL_new_term_ref();
2494
term_t stream = PL_new_term_ref();
2488
if ( !PL_strip_module(file, &m, name) )
2499
if ( !PL_strip_module(qstream, &m, stream) )
2490
if ( !PL_get_file_name(name, &fn, 0) )
2501
if ( !PL_get_stream_handle(stream, &fd) )
2504
saved_enc = fd->encoding;
2505
fd->encoding = ENC_OCTET;
2493
2506
LD->modules.source = m;
2494
rval = qlfLoad(fn, &m PASS_LD);
2507
rval = qlfLoad(fd, &m PASS_LD);
2495
2508
LD->modules.source = oldsrc;
2501
return PL_unify_atom(module, m->name);
2509
fd->encoding = saved_enc;
2513
return PL_unify_atom(module, m->name);
2503
2515
return PL_unify_integer(module, 0);
2786
2801
BeginPredDefs(wic)
2787
2802
PRED_DEF("$qlf_info", 5, qlf_info, 0)
2803
PRED_DEF("$qlf_load", 2, qlf_load, PL_FA_TRANSPARENT)