tarw.h
Minimalist header-only library for generating TAR files
- Commit
- 7b2b276279c7986db85c017f313405331d3db442
-
- Parent
- ab55601338cb5ed8a6a56612541779cff898a57d
-
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Improved tarw_write
Added a couple of zeroed chunks to the end of the output of taw_write, which is supposed to be the standard way to delimiting the end of the archive
Diffstats
1 files changed, 6 insertions, 1 deletions
| Status |
Name |
Changes |
Insertions |
Deletions |
| Modified |
tarw.h |
2 files changed |
6 |
1 |
diff --git a/tarw.h b/tarw.h
@@ -74,7 +74,7 @@ enum {
TARW_PIPE = '6', // TODO: unsupported
};
-// = Implementation ===========================================================
+// = implementation ===========================================================
#ifdef TARW_IMPLEMENTATION
#define TARW_USTARW_INDICATOR "ustar"
@@ -195,6 +195,11 @@ bool tarw_add_file(TarWriter *w, const char *path, uint16_t mode,
bool tarw_write(TarWriter w, FILE *f)
{
if (fwrite(w.data, 1, w.cursor, f) != w.cursor) return false;
+
+ const char eof_delim[2*TARW_CHUNK_SIZE] = {0};
+ if (fwrite(eof_delim, 1, sizeof(eof_delim), f) != sizeof(eof_delim))
+ return false;
+
return true;
}