Prolog "files"

Admin User, created Apr 14. 2024
         
/**
* Modern Albufeira Prolog Interpreter
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
:-(directory_member(F, N), ','(directory_files(F, L), member(N, L))).
:-(ensure_directory(F), ','(file_exists(F), ','(file_property(F, type(directory)), !))).
:-(ensure_directory(F), make_directory(F)).
:-(copy_text(InName, OutName), copy_text(InName, OutName, [])).
:-(copy_text(InName, OutName, Opt), ','(sys_copy_text_opts(Opt, 0, Flags), ','(;(->(=:=(/\(Flags, 1), 0), =(Mode, write)), =(Mode, append)), setup_once_cleanup(open(OutName, Mode, OutStream), sys_copy_stream(InName, OutStream), close(OutStream))))).
:-(copy_time(InName, OutName), copy_time(InName, OutName, [])).
:-(copy_time(InName, OutName, Opt), ','(sys_copy_time_opts(Opt, 0, Flags), ','(;(->(=:=(/\(Flags, 1), 0), =(Time2, 0)), file_property(OutName, last_modified(Time2))), ','(file_property(InName, last_modified(Time)), ;(->(>(Time, Time2), set_file_property(OutName, last_modified(Time))), true))))).
:-(sys_copy_stream(InName, OutStream), setup_once_cleanup(open(InName, read, InStream), sys_copy_lines(InStream, OutStream), close(InStream))).
:-(sys_copy_lines(InStream, OutStream), ','(enum_lines(InStream, Line), ','(write(OutStream, Line), fail))).
sys_copy_lines(_, _).
:-(enum_lines(InStream, Line), ','(repeat, ','(get_atom(InStream, 0'\n, Line), ;(->(\==(Line, ''), true), ','(!, fail))))).
:-(sys_copy_text_opts(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_copy_text_opts('.'(X, L), I, O), ','(!, ','(sys_copy_text_opt(X, I, H), sys_copy_text_opts(L, H, O)))).
:-(sys_copy_text_opts([], H, H), !).
:-(sys_copy_text_opts(L, _, _), throw(error(type_error(list, L), _))).
:-(sys_copy_text_opt(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_copy_text_opt(append(B), F, G), ','(!, sys_opt_boolean(B, 1, F, G))).
:-(sys_copy_text_opt(O, _, _), throw(error(type_error(bundlepy_option, O), _))).
:-(sys_copy_time_opts(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_copy_time_opts('.'(X, L), I, O), ','(!, ','(sys_copy_time_opt(X, I, H), sys_copy_time_opts(L, H, O)))).
:-(sys_copy_time_opts([], H, H), !).
:-(sys_copy_time_opts(L, _, _), throw(error(type_error(list, L), _))).
:-(sys_copy_time_opt(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_copy_time_opt(update(B), F, G), ','(!, sys_opt_boolean(B, 1, F, G))).
:-(sys_copy_time_opt(O, _, _), throw(error(type_error(bundlepy_option, O), _))).
:-(ensure_loaded(foreign(/(util, oslib)))).