1/*  Part of Ciao Prolog compatibility library
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@uva.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2010, University of Amsterdam
    8    This program is free software; you can redistribute it and/or
    9    modify it under the terms of the GNU General Public License
   10    as published by the Free Software Foundation; either version 2
   11    of the License, or (at your option) any later version.
   13    This program is distributed in the hope that it will be useful,
   14    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16    GNU General Public License for more details.
   18    You should have received a copy of the GNU General Public
   19    License along with this library; if not, write to the Free Software
   20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   22    As a special exception, if you link this library with other files,
   23    compiled with a Free Software compiler, to produce an executable, this
   24    library does not by itself cause the resulting executable to be covered
   25    by the GNU General Public License. This exception does not however
   26    invalidate any other reasons why the executable file might be covered by
   27    the GNU General Public License.
   30:- module(ciao_system,
   31	  [ pause/1,
   32	    time/1,
   33%	    datime/1,
   34%	    datime/9,
   35%	    getenvstr/2,
   36%	    setenvstr/2,
   37%	    extract_paths/2,
   38%	    get_pid/1,
   39	    current_host/1,
   40%	    current_executable/1,
   41%	    umask/2,
   42%	    make_directory/2,
   43%	    make_directory/1,
   44%	    make_dirpath/2,
   45%	    make_dirpath/1,
   46	    working_directory/2,
   47%	    cd/1,
   48	    shell/0,
   49	    shell/1,
   50	    shell/2,
   51%	    system/1,
   52%	    system/2,
   53	    popen/3,
   54%	    exec/4,
   55%	    exec/3,
   56%	    exec/8,
   57%	    wait/3,
   58%	    directory_files/2,
   59%	    mktemp/2,
   60%	    file_exists/1,
   61%	    file_exists/2,
   62%	    file_property/2,
   63%	    file_properties/6,
   64%	    modif_time/2,
   65%	    modif_time0/2,
   66%	    fmode/2,
   67%	    chmod/2,
   68%	    chmod/3,
   69	    mktemp_in_tmp/2,
   70	    delete_file/1,
   71	    delete_directory/1,
   72	    rename_file/2
   73%	    cyg2win/3
   74	  ]).   75:- use_module('../../socket').

Ciao system utlities

To be done
- Complete. Most of this is easily emulated. */
Make this thread sleep for some Seconds.
   87pause(Seconds) :-
   88	sleep(Seconds).
Time is unified with the number of seconds elapsed since January, 1, 1970 (UTC).
   95time(Time) :-
   96	get_time(Time).
 current_host(-Host) is det
Hostname is unified with the fully qualified name of the host.
  103current_host(Host) :-
  104	gethostname(Host).
 popen(+Command, +Mode, +Stream) is det
Open a pipe to process Command in a new shell with a given Mode and return a communication Stream (as in UNIX popen(3)). If Mode is read the output from the process is sent to Stream. If Mode is write, Stream is sent as input to the process. Stream may be read from or written into using the ordinary stream I/O predicates. Stream must be closed explicitly using close/1, i.e., it is not closed automatically when the process dies. Note that popen/2 is defined in ***x as using /bin/sh, which usually does not exist in Windows systems. In this case, a sh shell which comes with Windows is used.
  119popen(Command, Mode, Stream) :-
  120	open(pipe(Command), Mode, Stream).
 mktemp_in_tmp(+Template:atom, +FileName:atom) is det
Same as tmp_file/2.
  126mktemp_in_tmp(Template, FileName) :- tmp_file(Template, FileName)