Add truncate while open

This commit is contained in:
topjohnwu 2019-02-23 12:58:48 -05:00
parent 2ab17204c6
commit 267c59b1f1

View File

@ -66,8 +66,7 @@ cpio_entry::~cpio_entry() {
void cpio::dump(const char *file) { void cpio::dump(const char *file) {
fprintf(stderr, "Dump cpio: [%s]\n", file); fprintf(stderr, "Dump cpio: [%s]\n", file);
int fd = xopen(file, O_WRONLY | O_CREAT, 0644); FDOutStream fd_out(xopen(file, O_WRONLY | O_CREAT | O_TRUNC, 0644), true);
FDOutStream fd_out(fd, true);
output(fd_out); output(fd_out);
} }