CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Use archive_errno() instead of errno for libarchive errors.
authorTilman Sauerbeck <tilman@crux.nu>
Wed, 8 Nov 2006 19:35:33 +0000 (20:35 +0100)
committerTilman Sauerbeck <tilman@crux.nu>
Wed, 15 Nov 2006 19:34:22 +0000 (20:34 +0100)
pkgutil.cc
pkgutil.h

index 39f68f5d3eb707c1fe7276f5ffe92c84d591fac5..13543659cd774ebb40b2856e9a3c9afccbe54bb5 100644 (file)
@@ -349,7 +349,7 @@ pair<string, pkgutil::pkginfo_t> pkgutil::pkg_open(const string& filename) const
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
            ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
-               throw runtime_error_with_errno("could not open " + filename);
+               throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
 
        for (i = 0; archive_read_next_header(archive, &entry) ==
             ARCHIVE_OK; ++i) {
@@ -362,7 +362,7 @@ pair<string, pkgutil::pkginfo_t> pkgutil::pkg_open(const string& filename) const
 
                if (S_ISREG(status->st_mode) &&
                    archive_read_data_skip(archive) != ARCHIVE_OK)
-                       throw runtime_error_with_errno("could not read " + filename);
+                       throw runtime_error_with_errno("could not read " + filename, archive_errno(archive));
        }
    
        if (i == 0) {
@@ -390,7 +390,7 @@ void pkgutil::pkg_install(const string& filename, const set<string>& keep_list,
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
            ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
-               throw runtime_error_with_errno("could not open " + filename);
+               throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
 
        chdir(root.c_str());
 
@@ -499,7 +499,7 @@ void pkgutil::pkg_footprint(string& filename) const
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
            ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK)
-                throw runtime_error_with_errno("could not open " + filename);
+                throw runtime_error_with_errno("could not open " + filename, archive_errno(archive));
 
        for (i = 0; archive_read_next_header(archive, &entry) ==
             ARCHIVE_OK; ++i) {
@@ -559,7 +559,7 @@ void pkgutil::pkg_footprint(string& filename) const
                
                if (S_ISREG(status->st_mode) &&
                    archive_read_data_skip(archive))
-                        throw runtime_error_with_errno("could not read " + filename);
+                        throw runtime_error_with_errno("could not read " + filename, archive_errno(archive));
         }
    
         if (i == 0) {
index 4c74de5da4a06e2270caf8e3bbf83983510be778..03409df1b76860ab13d9fc02942af110d388fdba 100644 (file)
--- a/pkgutil.h
+++ b/pkgutil.h
@@ -91,6 +91,8 @@ class runtime_error_with_errno : public runtime_error {
 public:
        explicit runtime_error_with_errno(const string& msg) throw()
                : runtime_error(msg + string(": ") + strerror(errno)) {}
+       explicit runtime_error_with_errno(const string& msg, int e) throw()
+               : runtime_error(msg + string(": ") + strerror(e)) {}
 };
 
 // Utility functions