rewrite
This commit is contained in:
parent
48db20515f
commit
78327cf885
66
pl/absf.yap
66
pl/absf.yap
@ -193,20 +193,19 @@ absolute_file_name(File0,File) :-
|
|||||||
(
|
(
|
||||||
First == first
|
First == first
|
||||||
->
|
->
|
||||||
'$absf_trace'(' got first ~a', [TrueFileName]),
|
'$absf_trace'(' |------- got first ~a', [TrueFileName]),
|
||||||
% stop_low_level_trace,
|
|
||||||
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
||||||
set_prolog_flag( open_expands_filename, OldF),
|
set_prolog_flag( open_expands_filename, OldF),
|
||||||
set_prolog_flag( verbose_file_search, PreviousVerbose ),
|
set_prolog_flag( verbose_file_search, PreviousVerbose ),
|
||||||
!
|
!
|
||||||
;
|
;
|
||||||
(
|
(
|
||||||
'$absf_trace'(' found match ~a.', [TrueFileName]),
|
'$absf_trace'(' +------- found match ~a.', [TrueFileName]),
|
||||||
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
||||||
set_prolog_flag( file_name_variables, OldF),
|
set_prolog_flag( file_name_variables, OldF),
|
||||||
set_prolog_flag( verbose_file_search, PreviousVerbose )
|
set_prolog_flag( verbose_file_search, PreviousVerbose )
|
||||||
;
|
;
|
||||||
'$absf_trace'(' no more solutions.', []),
|
'$absf_trace'(' -------- no more solutions.', []),
|
||||||
set_prolog_flag( verbose_file_search, Verbose ),
|
set_prolog_flag( verbose_file_search, Verbose ),
|
||||||
get_abs_file_parameter( file_errors, Opts, FErrors ),
|
get_abs_file_parameter( file_errors, Opts, FErrors ),
|
||||||
set_prolog_flag(file_name_variables, Expand),
|
set_prolog_flag(file_name_variables, Expand),
|
||||||
@ -215,7 +214,7 @@ absolute_file_name(File0,File) :-
|
|||||||
;
|
;
|
||||||
% no solution
|
% no solution
|
||||||
% stop_low_level_trace,
|
% stop_low_level_trace,
|
||||||
'$absf_trace'(' failed.', []),
|
'$absf_trace'(' !------- failed.', []),
|
||||||
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
set_prolog_flag( fileerrors, PreviousFileErrors ),
|
||||||
set_prolog_flag( verbose_file_search, PreviousVerbose ),
|
set_prolog_flag( verbose_file_search, PreviousVerbose ),
|
||||||
set_prolog_flag(file_name_variables, OldF),
|
set_prolog_flag(file_name_variables, OldF),
|
||||||
@ -240,14 +239,16 @@ absolute_file_name(File0,File) :-
|
|||||||
'$absf_trace'('start with ~w', [Name]),
|
'$absf_trace'('start with ~w', [Name]),
|
||||||
'$core_file_name'(Name, Opts, CorePath, []),
|
'$core_file_name'(Name, Opts, CorePath, []),
|
||||||
'$absf_trace'(' after name/library unfolding: ~w', [Name]),
|
'$absf_trace'(' after name/library unfolding: ~w', [Name]),
|
||||||
'$prefix'(CorePath, Opts, Path , CorePath),
|
'$variable_expansion'(CorePath, Opts,ExpandedPath),
|
||||||
|
'$absf_trace'(' after environment variable expansion: ~s', [ExpandedPath]),
|
||||||
|
'$prefix'(ExpandedPath, Opts, Path , []),
|
||||||
'$absf_trace'(' after prefix expansion: ~s', [Path]),
|
'$absf_trace'(' after prefix expansion: ~s', [Path]),
|
||||||
atom_codes( APath, Path ),
|
atom_codes( APath, Path ),
|
||||||
(
|
(
|
||||||
Expand = true
|
Expand = true
|
||||||
->
|
->
|
||||||
expand_file_name( APath, EPaths),
|
expand_file_name( APath, EPaths),
|
||||||
'$absf_trace'(' after variable expansion/globbing: ~w', [EPaths]),
|
'$absf_trace'(' after shell globbing: ~w', [EPaths]),
|
||||||
lists:member(EPath, EPaths)
|
lists:member(EPath, EPaths)
|
||||||
;
|
;
|
||||||
EPath = APath
|
EPath = APath
|
||||||
@ -294,23 +295,13 @@ real_path( EPath, File),
|
|||||||
!,
|
!,
|
||||||
S.
|
S.
|
||||||
|
|
||||||
% / separates both unix and windows path
|
|
||||||
'$absolute_path'( [0'/|_], _Opts ) :- !.
|
'$variable_expansion'( Path, Opts, APath ) :-
|
||||||
'$absolute_path'( [0'~|_], Opts ) :-
|
|
||||||
get_abs_file_parameter( expand, Opts, true ),
|
get_abs_file_parameter( expand, Opts, true ),
|
||||||
!.
|
!,
|
||||||
'$absolute_path'( [0'$|L], Opts ) :-
|
'$expand_file_name'( Path, APath ).
|
||||||
get_abs_file_parameter( expand, Opts, true ),
|
'$variable_expansion'( Path, _, Path ).
|
||||||
'$var'(L),
|
|
||||||
!.
|
|
||||||
% \ windows path
|
|
||||||
'$absolute_path'( [0'\\|_], _Opts ) :-
|
|
||||||
current_prolog_flag(windows, true),
|
|
||||||
!.
|
|
||||||
% windows drive
|
|
||||||
'$absolute_path'( Path, _Opts ) :-
|
|
||||||
current_prolog_flag(windows, true),
|
|
||||||
'$drive'( Path, _ ).
|
|
||||||
|
|
||||||
'$var'(S) -->
|
'$var'(S) -->
|
||||||
"{", !, '$id'(S), "}".
|
"{", !, '$id'(S), "}".
|
||||||
@ -321,7 +312,7 @@ real_path( EPath, File),
|
|||||||
'$id'(_),
|
'$id'(_),
|
||||||
":\\\\".
|
":\\\\".
|
||||||
|
|
||||||
'$id'([C|S]) --> [S],
|
'$id'([C|S]) --> [C],
|
||||||
{ C >= "a", C =< "z" ; C >= "A", C =< "Z" ;
|
{ C >= "a", C =< "z" ; C >= "A", C =< "Z" ;
|
||||||
C >= "0", C =< "9" ; C =:= "_" },
|
C >= "0", C =< "9" ; C =:= "_" },
|
||||||
!,
|
!,
|
||||||
@ -334,9 +325,11 @@ real_path( EPath, File),
|
|||||||
!,
|
!,
|
||||||
exists_directory(F).
|
exists_directory(F).
|
||||||
'$check_file'(_F, _Type, none) :- !.
|
'$check_file'(_F, _Type, none) :- !.
|
||||||
|
'$check_file'(F, _Type, exist) :-
|
||||||
|
'$access_file'(F, exist). % if it has a type cannot be a directory..
|
||||||
'$check_file'(F, _Type, Access) :-
|
'$check_file'(F, _Type, Access) :-
|
||||||
'$access_file'(F, Access),
|
'$access_file'(F, Access),
|
||||||
\+ exists_directory(F). % if it has a type cannot be a directory..
|
\+ exists_directory(F). % if it has a type cannot be a directory..
|
||||||
|
|
||||||
'$suffix'(Last, _Opts) -->
|
'$suffix'(Last, _Opts) -->
|
||||||
{ lists:append(_, [0'.|Alphas], Last), '$id'(Alphas, _, [] ) },
|
{ lists:append(_, [0'.|Alphas], Last), '$id'(Alphas, _, [] ) },
|
||||||
@ -388,11 +381,11 @@ real_path( EPath, File),
|
|||||||
Base \= '.',
|
Base \= '.',
|
||||||
Base \='..'.
|
Base \='..'.
|
||||||
|
|
||||||
|
'$prefix'( CorePath, _Opts) -->
|
||||||
|
{ is_absolute_file_name( CorePath ) },
|
||||||
|
!,
|
||||||
|
CorePath.
|
||||||
'$prefix'( CorePath, Opts) -->
|
'$prefix'( CorePath, Opts) -->
|
||||||
{ '$absolute_path'( CorePath, Opts ) },
|
|
||||||
'$absf_trace'(' rooted ~s', [CorePath]),
|
|
||||||
!.
|
|
||||||
'$prefix'( _, Opts) -->
|
|
||||||
{ get_abs_file_parameter( relative_to, Opts, Prefix ),
|
{ get_abs_file_parameter( relative_to, Opts, Prefix ),
|
||||||
Prefix \= '',
|
Prefix \= '',
|
||||||
'$absf_trace'(' relative_to ~a', [Prefix]),
|
'$absf_trace'(' relative_to ~a', [Prefix]),
|
||||||
@ -401,17 +394,20 @@ real_path( EPath, File),
|
|||||||
},
|
},
|
||||||
!,
|
!,
|
||||||
S,
|
S,
|
||||||
'$dir'(Last).
|
'$dir'(Last),
|
||||||
'$prefix'( _ , _) -->
|
CorePath.
|
||||||
|
'$prefix'( CorePath, _) -->
|
||||||
{
|
{
|
||||||
recorded('$path',Prefix,_),
|
recorded('$path',Prefix,_),
|
||||||
'$absf_trace'(' try YAP path database ~a', [Prefix]),
|
'$absf_trace'(' try YAP path database ~a', [Prefix]),
|
||||||
sub_atom(Prefix, _, _, 1, Last),
|
sub_atom(Prefix, _, _, 1, Last),
|
||||||
atom_codes(Prefix, S) },
|
atom_codes(Prefix, S) },
|
||||||
S,
|
S,
|
||||||
'$dir'(Last).
|
'$dir'(Last),
|
||||||
'$prefix'(_,_ ) -->
|
CorePath.
|
||||||
'$absf_trace'(' empty prefix', []).
|
'$prefix'(CorePath, _ ) -->
|
||||||
|
'$absf_trace'(' empty prefix', []),
|
||||||
|
CorePath.
|
||||||
|
|
||||||
|
|
||||||
'$dir' --> { current_prolog_flag(windows, true) },
|
'$dir' --> { current_prolog_flag(windows, true) },
|
||||||
|
Reference in New Issue
Block a user