fix ProbLog path issues

This commit is contained in:
Vítor Santos Costa 2015-04-21 09:25:12 -06:00
parent 76cd423784
commit e963c59649
1 changed files with 28 additions and 45 deletions

View File

@ -1,4 +1,4 @@
<%%% -*- Mode: Prolog; -*-
%%% -*- Mode: Prolog; -*-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@ -236,10 +236,27 @@
%=
%========================================================================
set_problog_path(Path):-
set_problog_path(File_Name, Path):-
retractall(problog_path(_)),
getenv('PATH',Dirs),
path_separator( PathSep ),
set_problog_paths( Dirs, PathSep, Path ),
assertz(problog_path(Path)),
fail.
set_problog_path(Path):-
assertz(problog_path(Path)).
set_problog_paths( Dirs, PathSep, Path ) :-
atomic_list_concat( [Path,LPaths], PathSep, Dirs),
(
true
;
set_problog_paths( LPaths, PathSep, Path )
).
%========================================================================
%=
%=
@ -264,20 +281,10 @@ convert_filename_to_problog_path(File_Name, Path):-
concat_path_with_filename(Path, File_Name, Result):-
nonvar(File_Name),
nonvar(Path),
% make sure, that there is no path delimiter at the end
prolog_file_name(Path,Path_Absolute),
path_seperator(Path_Seperator),
atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result).
concat_path_with_filename2(Path, File_Name, Result):-
nonvar(File_Name),
nonvar(Path),
path_seperator(Path_Seperator),
(atomic_concat(Path_Absolute, Path_Seperator, Path) ; Path_Absolute = Path),
atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result).
path_separator(Path_Seperator),
atomic_list_concat([Path_Absolute, Path_Seperator, File_Name], Result).
%========================================================================
%= Calculate the MD5 checksum of +Filename by calling md5sum
@ -300,7 +307,6 @@ calc_md5_intern(Filename,Command,MD5) :-
( file_exists(Filename) -> true ; throw(md5_file(Filename)) ),
atomic_concat([Command,' "',Filename,'"'],Call),
% execute the md5 command
exec(Call,[null,pipe(S),null],PID),
bb_put(calc_md5_temp,End-End), % use difference list
@ -345,32 +351,6 @@ calc_md5_intern(Filename,Command,MD5) :-
%=
%========================================================================
path_seperator('\\'):-
yap_flag(windows, true), !.
path_seperator('/').
%========================================================================
%=
%=
%=
%========================================================================
split_path_file(PathFile, Path, File):-
path_seperator(PathSeperator),
name(PathSeperator, [PathSeperatorName]),
atomic_concat(Path, File, PathFile),
name(File, FileName),
\+ memberchk(PathSeperatorName, FileName),
!.
%========================================================================
%=
%=
%=
%========================================================================
check_existance(FileName):-
convert_filename_to_problog_path(FileName, Path),
@ -379,3 +359,6 @@ check_existance(FileName):-
problog_path(PD),
write(user_error, 'WARNING: Can not find file: '), write(user_error, FileName),
write(user_error, ', please place file in problog path: '), write(user_error, PD), nl(user_error).
path_separator(PathSep) :-
( current_prolog_flag( windows, true ) -> PathSep = ';' ; PathSep = ':' ).