#include <archive_entry.h>
#define INIT_ARCHIVE(ar) \
- archive_read_support_compression_gzip((ar)); \
- archive_read_support_compression_bzip2((ar)); \
- archive_read_support_compression_xz((ar)); \
+ archive_read_support_filter_gzip((ar)); \
+ archive_read_support_filter_bzip2((ar)); \
+ archive_read_support_filter_xz((ar)); \
archive_read_support_format_tar((ar))
+#define DEFAULT_BYTES_PER_BLOCK (20 * 512)
+
using __gnu_cxx::stdio_filebuf;
pkgutil::pkgutil(const string& name)
INIT_ARCHIVE(archive);
if (archive_read_open_filename(archive,
- const_cast<char*>(filename.c_str()),
- ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
+ filename.c_str(),
+ DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
for (i = 0; archive_read_next_header(archive, &entry) ==
throw runtime_error("could not read " + filename);
}
- archive_read_finish(archive);
+ archive_read_free(archive);
return result;
}
INIT_ARCHIVE(archive);
if (archive_read_open_filename(archive,
- const_cast<char*>(filename.c_str()),
- ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
+ filename.c_str(),
+ DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
chdir(root.c_str());
throw runtime_error("could not read " + filename);
}
- archive_read_finish(archive);
+ archive_read_free(archive);
}
void pkgutil::ldconfig() const
INIT_ARCHIVE(archive);
if (archive_read_open_filename(archive,
- const_cast<char*>(filename.c_str()),
- ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
+ filename.c_str(),
+ DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
for (i = 0; archive_read_next_header(archive, &entry) ==
throw runtime_error_with_errno("could not read " + filename, archive_errno(archive));
}
- archive_read_finish(archive);
+ archive_read_free(archive);
// Too bad, there doesn't seem to be a way to reuse our archive
// instance
INIT_ARCHIVE(archive);
if (archive_read_open_filename(archive,
- const_cast<char*>(filename.c_str()),
- ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
+ filename.c_str(),
+ DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
for (i = 0; archive_read_next_header(archive, &entry) ==
throw runtime_error("could not read " + filename);
}
- archive_read_finish(archive);
+ archive_read_free(archive);
}
void pkgutil::print_version() const