rewrote so no libarchive