51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
|
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");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|