In windows there is SetEndOfFile() API to cut out some data in the end.
How do I do this in Linux?
The pseudo-code sample of what I'm looking for (Linux-specific):
int fd = open("/path/to/file",O_RDWR);
// file contents: "0123456789ABCDEF", 16 bytes
lseek(fd,10,SEEK_CUR);
// what's in the next line? (imaginary code)
syscall(what,fd,FD_SET_EOF);
close(fd);
//sync();
// now file on disk looks like "0123456789", 10 bytes
ftruncate(fd, 10);
(The
lseek
call isn't needed.)man 2 ftruncate