summaryrefslogtreecommitdiff
path: root/archival/libunarchive/data_extract_all.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-12-16 23:18:59 +0100
committerDenys Vlasenko2009-12-16 23:18:59 +0100
commit8a936cfab718aee9f304f1b41e6b16cf6b5999f9 (patch)
tree5ae3e37a204a8d13e7e70b84a48ec415e464e98a /archival/libunarchive/data_extract_all.c
parent425ad9c93b2736a0ebfbba6267bc1ad56c49d156 (diff)
downloadbusybox-8a936cfab718aee9f304f1b41e6b16cf6b5999f9.zip
busybox-8a936cfab718aee9f304f1b41e6b16cf6b5999f9.tar.gz
tar: add support for --overwrite. +70 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libunarchive/data_extract_all.c')
-rw-r--r--archival/libunarchive/data_extract_all.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index ae242df..874d37d 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -72,8 +72,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
switch (file_header->mode & S_IFMT) {
case S_IFREG: {
/* Regular file */
+ int flags = O_WRONLY | O_CREAT | O_EXCL;
+ if (archive_handle->ah_flags & ARCHIVE_O_TRUNC)
+ flags = O_WRONLY | O_CREAT | O_TRUNC;
dst_fd = xopen3(file_header->name,
- O_WRONLY | O_CREAT | O_EXCL,
+ flags,
file_header->mode
);
bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size);