Skip to content

Commit

Permalink
Merge pull request #38 from Leonidas-from-XIV/bugfix/optional-finish-…
Browse files Browse the repository at this point in the history
…entry

Make calls to the finish_entry callback optional
  • Loading branch information
kientzle committed Feb 17, 2013
2 parents e567c8c + 2054e02 commit 59cf95f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libarchive/archive_write.c
Expand Up @@ -503,8 +503,9 @@ _archive_write_close(struct archive *_a)

archive_clear_error(&a->archive);

/* Finish the last entry. */
if (a->archive.state == ARCHIVE_STATE_DATA)
/* Finish the last entry if a finish callback is specified */
if (a->archive.state == ARCHIVE_STATE_DATA
&& a->format_finish_entry != NULL)
r = ((a->format_finish_entry)(a));

/* Finish off the archive. */
Expand Down Expand Up @@ -658,7 +659,8 @@ _archive_write_finish_entry(struct archive *_a)
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_write_finish_entry");
if (a->archive.state & ARCHIVE_STATE_DATA)
if (a->archive.state & ARCHIVE_STATE_DATA
&& a->format_finish_entry != NULL)
ret = (a->format_finish_entry)(a);
a->archive.state = ARCHIVE_STATE_HEADER;
return (ret);
Expand Down

0 comments on commit 59cf95f

Please sign in to comment.