在Windows中,有SetEndOfFile()API可以最终删除一些数据。
我如何在Linux中执行此操作?
我正在寻找的伪代码示例(特定于Linux):
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