Truncate n bytes from end of file

Share:

Description

Truncate n bytes from end of file

Usage

1
truncateEndOfFile(filename, len)

Arguments

filename

character. Filename.

len

numeric. Number of bytes to truncate

Author(s)

Kaiyin Zhong

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
fn = tempfile()
f = file(fn, "wb")
writeBin("a", f)
writeBin("b", f)
writeBin("c", f)
close(f)
file.info(fn)$size == 6
truncateEndOfFile(fn, 1)
file.info(fn)$size == 5

## End(Not run)