X-Git-Url: http://gitweb/?a=blobdiff_plain;ds=sidebyside;f=pkgutil.cc;h=216ca531de2dd92d507d474b42b5d3f8ccc70aad;hb=c67507556d9eaa476ec142762f041fd9b254655d;hp=62a9edf73fd08b44b3ddc651a0b0c74f1d3373eb;hpb=2a62ed9ad2688a873bc7773b2c3cf818456aeabb;p=pkgutils-cross.git diff --git a/pkgutil.cc b/pkgutil.cc index 62a9edf..216ca53 100644 --- a/pkgutil.cc +++ b/pkgutil.cc @@ -2,6 +2,7 @@ // pkgutils // // Copyright (c) 2000-2005 Per Liden +// Copyright (c) 2006-2007 by CRUX team (http://crux.nu) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -38,11 +39,14 @@ #include #include #include -#include #include #include #include +#define INIT_ARCHIVE(ar) \ + archive_read_support_compression_all((ar)); \ + archive_read_support_format_all((ar)) + using __gnu_cxx::stdio_filebuf; pkgutil::pkgutil(const string& name) @@ -343,8 +347,7 @@ pair pkgutil::pkg_open(const string& filename) const result.second.version = version; archive = archive_read_new(); - archive_read_support_compression_all(archive); - archive_read_support_format_all(archive); + INIT_ARCHIVE(archive); if (archive_read_open_filename(archive, const_cast(filename.c_str()), @@ -383,8 +386,7 @@ void pkgutil::pkg_install(const string& filename, const set& keep_list, unsigned int i; archive = archive_read_new(); - archive_read_support_compression_all(archive); - archive_read_support_format_all(archive); + INIT_ARCHIVE(archive); if (archive_read_open_filename(archive, const_cast(filename.c_str()), @@ -422,7 +424,7 @@ void pkgutil::pkg_install(const string& filename, const set& keep_list, (real_filename.c_str())); // Extract file - unsigned int flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_UNLINK; + unsigned int flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK; if (archive_read_extract(archive, entry, flags) != ARCHIVE_OK) { // If a file fails to install we just print an error message and @@ -499,8 +501,7 @@ void pkgutil::pkg_footprint(string& filename) const // // FIXME the code duplication here is butt ugly archive = archive_read_new(); - archive_read_support_compression_all(archive); - archive_read_support_format_all(archive); + INIT_ARCHIVE(archive); if (archive_read_open_filename(archive, const_cast(filename.c_str()), @@ -527,8 +528,7 @@ void pkgutil::pkg_footprint(string& filename) const // Too bad, there doesn't seem to be a way to reuse our archive // instance archive = archive_read_new(); - archive_read_support_compression_all(archive); - archive_read_support_format_all(archive); + INIT_ARCHIVE(archive); if (archive_read_open_filename(archive, const_cast(filename.c_str()), @@ -699,42 +699,6 @@ string mtos(mode_t mode) return s; } -int unistd_gzopen(char* pathname, int flags, mode_t mode) -{ - char* gz_mode; - - switch (flags & O_ACCMODE) { - case O_WRONLY: - gz_mode = "w"; - break; - - case O_RDONLY: - gz_mode = "r"; - break; - - case O_RDWR: - default: - errno = EINVAL; - return -1; - } - - int fd; - gzFile gz_file; - - if ((fd = open(pathname, flags, mode)) == -1) - return -1; - - if ((flags & O_CREAT) && fchmod(fd, mode)) - return -1; - - if (!(gz_file = gzdopen(fd, gz_mode))) { - errno = ENOMEM; - return -1; - } - - return (int)gz_file; -} - string trim_filename(const string& filename) { string search("//");