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).
?- 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)