
stream_truncate(+Stream)

   Truncate Stream at the current position

Arguments
   Stream              Integer (stream number) or Atom (reserved or user-defined symbolic stream name).

Type
   Stream I/O

Description
    Used to truncate a stream, i.e. to remove all contents beyond the
    current (write) position.  As a consequence, immediately after this
    operation the stream is at end of file.
    
    This operation only makes sense on file-streams and string streams
    which are open for writing (or updating). On all other types of streams,
    the predicate silently succeeds.
    
    Files will be physically truncated, i.e. their size is trimmed and extra
    disk space returned to the operating system. String streams will free
    any unnecessary buffer memory.
    
    Note: When opening an existing file for writing (not updating), the
    file is automatically truncated to size zero (see open/3,4).


Modes and Determinism
   stream_truncate(+) is det

Exceptions
     4 --- Stream is not instantiated.
     5 --- Stream is instantiated, but not to an atom or an integer.
   192 --- Stream is not open in write mode.

Examples
   
	?- open(string("hellothere"), update, s).
	Yes (0.00s cpu)

	?- seek(s, 5).
	Yes (0.00s cpu)

	?- at_eof(s).
	No (0.00s cpu)

	?- stream_truncate(s).
	Yes (0.00s cpu)

	?- at_eof(s).
	Yes (0.00s cpu)

	?- seek(s,0).
	Yes (0.00s cpu)

	?- read_string(s, end_of_file, _, S).
	S = "hello"
	Yes (0.00s cpu)


See Also
   at_eof / 1, seek / 2, open / 3, open / 4
