minor incompats

This commit is contained in:
Vítor Santos Costa 2015-04-21 16:12:01 -06:00
parent 742c299672
commit e043e7595e
3 changed files with 44 additions and 25 deletions

View File

@ -6,7 +6,7 @@
% $Revision: 6764 $ % $Revision: 6764 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
% %
% ProbLog was developed at Katholieke Universiteit Leuven % ProbLog was developed at Katholieke Universiteit Leuven
% %
@ -236,26 +236,28 @@
%= %=
%======================================================================== %========================================================================
set_problog_path(File_Name, Path):- set_problog_path( _Path):-
retractall(problog_path(_)), retractall(problog_path(_)),
getenv('PATH',Dirs), getenv('PATH',Dirs),
path_separator( PathSep ), path_grouping( PathSep ),
set_problog_paths( Dirs, PathSep, Path ), atomic_list_concat( LPaths, PathSep, Dirs),
assertz(problog_path(Path)), set_problog_paths( LPaths ),
fail. fail.
set_problog_path(Path):- set_problog_path(Path):-
assertz(problog_path(Path)). path_separator( S ),
sub_atom(Path, _, 1, 0, S), !,
sub_atom(Path, _, _, 1, Path0),
asserta(problog_path(Path0)).
set_problog_path(Path):-
asserta(problog_path(Path)).
set_problog_paths( Dirs, PathSep, Path ) :- set_problog_paths( [Path|Paths] ) :-
atomic_list_concat( [Path,LPaths], PathSep, Dirs), assertz(problog_path(Path)),
( set_problog_paths( Paths ).
true set_problog_paths( [] ).
;
set_problog_paths( LPaths, PathSep, Path )
).
%======================================================================== %========================================================================
%= %=
@ -269,7 +271,8 @@ convert_filename_to_working_path(File_Name, Path):-
convert_filename_to_problog_path(File_Name, Path):- convert_filename_to_problog_path(File_Name, Path):-
problog_path(Dir), problog_path(Dir),
concat_path_with_filename(Dir, File_Name, Path). concat_path_with_filename(Dir, File_Name, Path),
catch(file_exists(Path), _, fail).
%======================================================================== %========================================================================
@ -279,12 +282,8 @@ convert_filename_to_problog_path(File_Name, Path):-
%======================================================================== %========================================================================
concat_path_with_filename(Path, File_Name, Result):- 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_separator(Path_Seperator), path_separator(Path_Seperator),
atomic_list_concat([Path_Absolute, Path_Seperator, File_Name], Result). atomic_list_concat([Path, Path_Seperator, File_Name], Result).
%======================================================================== %========================================================================
%= Calculate the MD5 checksum of +Filename by calling md5sum %= Calculate the MD5 checksum of +Filename by calling md5sum
@ -315,7 +314,7 @@ calc_md5_intern(Filename,Command,MD5) :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
( % read 32 Bytes from stdout of process ( % read 32 Bytes from stdout of process
repeat, repeat,
get_code(S,C), get_byte(S,C),
( (
C== -1 C== -1
@ -354,11 +353,16 @@ calc_md5_intern(Filename,Command,MD5) :-
check_existance(FileName):- check_existance(FileName):-
convert_filename_to_problog_path(FileName, Path), convert_filename_to_problog_path(FileName, Path),
catch(file_exists(Path), _, fail). catch(file_exists(Path), _, fail), !.
check_existance(FileName):- check_existance(FileName):-
problog_path(PD), problog_path(PD),
write(user_error, 'WARNING: Can not find file: '), write(user_error, FileName), 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). write(user_error, ', please place file in problog path: '), write(user_error, PD), nl(user_error).
path_separator(PathSep) :- path_grouping(PathSep) :-
( current_prolog_flag( windows, true ) -> PathSep = ';' ; PathSep = ':' ). ( current_prolog_flag( windows, true ) -> PathSep = ';' ; PathSep = ':' ).
path_separator('\\') :-
current_prolog_flag( windows, true ).
path_separator('/').

View File

@ -328,8 +328,8 @@ prefix_bdd_file_with_header(BDD_File_Name,VarCount,IntermediateSteps,TmpFile) :-
( (
repeat, repeat,
get_byte(H2,C), get_code(H2,C),
put_byte(H,C), put_code(H,C),
at_end_of_stream(H2), at_end_of_stream(H2),
! !
), ),

View File

@ -293,6 +293,21 @@ create_bdd_output_file_name(QueryID,ClusterID,Iteration,Absolute_File_Name) :-
concat_path_with_filename(Path,File_Name,Absolute_File_Name). concat_path_with_filename(Path,File_Name,Absolute_File_Name).
create_bdd_output_file_name(_,_,_,_) :- create_bdd_output_file_name(_,_,_,_) :-
throw(error(problog_flag_does_not_exist(output_directory))). throw(error(problog_flag_does_not_exist(output_directory))).
%========================================================================
%=
%=
%========================================================================
create_bdd_file_name(QueryID,ClusterID,Absolute_File_Name) :-
problog_flag(output_directory,Path),
!,
atomic_concat([',_query_',QueryID,'_cluster_',ClusterID],File_Name),
concat_path_with_filename(Path,File_Name,Absolute_File_Name).
create_bdd_output_file_name(_,_,_) :-
throw(error(problog_flag_does_not_exist(output_directory))).
%======================================================================== %========================================================================
%= %=
%= %=