diff options
Diffstat (limited to 'Utilities/cmlibarchive/examples/minitar/notes')
-rw-r--r-- | Utilities/cmlibarchive/examples/minitar/notes | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Utilities/cmlibarchive/examples/minitar/notes b/Utilities/cmlibarchive/examples/minitar/notes new file mode 100644 index 0000000..79728d4 --- /dev/null +++ b/Utilities/cmlibarchive/examples/minitar/notes @@ -0,0 +1,50 @@ +create(const char* filename) +{ + struct archive *a; + a = archive_write_new(); +// pick a compression type + archive_write_set_compression_bzip2(a); + archive_write_set_compression_compress(a); + archive_write_set_compression_gzip(a); + archive_write_set_compression_none(a); + +// what does this do??? + archive_write_set_format_ustar(a); // is this what we want? +// maybe this: + archive_write_set_format_pax(a); + + archive_write_open_file(a, filename); + + struct archive* disk = archive_read_disk_new(); + archive_read_disk_set_standard_lookup(disk); + while (*argv != NULL) + { + struct tree *t = tree_open(*argv); + while (tree_next(t)) + { + entry = archive_entry_new(); + archive_entry_set_pathname(entry, tree_current_path(t)); + archive_read_disk_entry_from_file(disk, entry, -1, + tree_current_stat(t)); + if (verbose) + { + msg("a "); + msg(tree_current_path(t)); + } + archive_write_header(a, entry); + int fd = open(tree_current_access_path(t), O_RDONLY); + char buff[16384]; + len = read(fd, buff, sizeof(buff)); + while (len > 0) + { + archive_write_data(a, buff, len); + len = read(fd, buff, sizeof(buff)); + } + close(fd); + archive_entry_free(entry); + if (verbose) + msg("\n"); + } + } + +} |