append .pl to names of files that do not exist in loader.pl
This commit is contained in:
@@ -308,11 +308,13 @@ use_module(Module, Exports) :-
|
|||||||
|
|
||||||
load_context_path(Module, Path) :-
|
load_context_path(Module, Path) :-
|
||||||
( prolog_load_context(directory, CurrentDir) ->
|
( prolog_load_context(directory, CurrentDir) ->
|
||||||
atom_concat(CurrentDir, Path, Module)
|
% Rust's Path module never ends a directory path with '/', so
|
||||||
|
% add one here.
|
||||||
|
atom_concat(CurrentDir, '/', CurrentDirSlashed),
|
||||||
|
atom_concat(CurrentDirSlashed, Module, Path)
|
||||||
; Module = Path
|
; Module = Path
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
path_atom(Dir/File, Path) :-
|
path_atom(Dir/File, Path) :-
|
||||||
must_be(atom, File),
|
must_be(atom, File),
|
||||||
!,
|
!,
|
||||||
@@ -321,6 +323,18 @@ path_atom(Dir/File, Path) :-
|
|||||||
path_atom(Path, Path) :-
|
path_atom(Path, Path) :-
|
||||||
must_be(atom, Path).
|
must_be(atom, Path).
|
||||||
|
|
||||||
|
% Try to open the file with the Path name as given; if that fails,
|
||||||
|
% append '.pl' and try again.
|
||||||
|
open_file(Path, Stream) :-
|
||||||
|
( atom_concat(_, '.pl', Path) ->
|
||||||
|
open(Path, read, Stream)
|
||||||
|
; catch(open(Path, read, Stream),
|
||||||
|
error(existence_error(source_sink, Path), _),
|
||||||
|
( atom_concat(Path, '.pl', ExtendedPath),
|
||||||
|
open(ExtendedPath, read, Stream) )
|
||||||
|
)
|
||||||
|
).
|
||||||
|
|
||||||
use_module(Module, Exports, Evacuable) :-
|
use_module(Module, Exports, Evacuable) :-
|
||||||
( var(Module) ->
|
( var(Module) ->
|
||||||
instantiation_error(load/1)
|
instantiation_error(load/1)
|
||||||
@@ -338,7 +352,7 @@ use_module(Module, Exports, Evacuable) :-
|
|||||||
)
|
)
|
||||||
; ( path_atom(Module, ModulePath) ->
|
; ( path_atom(Module, ModulePath) ->
|
||||||
load_context_path(ModulePath, Path),
|
load_context_path(ModulePath, Path),
|
||||||
open(Path, read, Stream),
|
open_file(Path, Stream),
|
||||||
file_load(Stream, Path, Subevacuable),
|
file_load(Stream, Path, Subevacuable),
|
||||||
'$use_module'(Evacuable, Subevacuable, Exports)
|
'$use_module'(Evacuable, Subevacuable, Exports)
|
||||||
; type_error(atom, Library, load/1)
|
; type_error(atom, Library, load/1)
|
||||||
@@ -375,7 +389,9 @@ load_context(Module) :-
|
|||||||
predicate_property(Callable, Property) :-
|
predicate_property(Callable, Property) :-
|
||||||
( var(Callable) ->
|
( var(Callable) ->
|
||||||
instantiation_error(load/1)
|
instantiation_error(load/1)
|
||||||
; Callable =.. [(:), Module, Callable0],
|
; functor(Callable, (:), 2), % Callable =.. [(:), Module, Callable0],
|
||||||
|
arg(1, Callable, Module),
|
||||||
|
arg(2, Callable, Callable0),
|
||||||
atom(Module) ->
|
atom(Module) ->
|
||||||
functor(Callable0, Name, Arity),
|
functor(Callable0, Name, Arity),
|
||||||
( atom(Name),
|
( atom(Name),
|
||||||
|
|||||||
Reference in New Issue
Block a user