Capy-Bearer Documentation

file_truncate

host call

Capy

function file_truncate(path : string, size : u64) bool

Description

file_truncate sets a file length. A smaller length removes trailing bytes.

Parameters

path : file path

size : new file length in bytes

Return Values

true if Capy changes the file length. Otherwise, false.

Example

Capy

file_put_contents("/tmp/doc-truncate.txt", "hello world")
if file_truncate("/tmp/doc-truncate.txt", u64(5)) {
    print(file_get_contents("/tmp/doc-truncate.txt"), "\n")
}