]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
cpio doesn't need set_fmode(O_BINARY) any more so we can remove it.
authorTim Kientzle <kientzle@gmail.com>
Sun, 28 Jun 2009 08:08:04 +0000 (04:08 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 28 Jun 2009 08:08:04 +0000 (04:08 -0400)
Also, fix up the uid/gid formatting to work properly on Windows (whose printf() functions don't support ISO C99).

SVN-Revision: 1201

cpio/cpio.c

index a4cebd3aaef5d20dc779b88bd830a2b54564730e..75cc8776d77a5eb33563564f45c9784205066c69 100644 (file)
@@ -126,12 +126,6 @@ main(int argc, char *argv[])
        memset(cpio, 0, sizeof(*cpio));
        cpio->buff = buff;
        cpio->buff_size = sizeof(buff);
-#if defined(_WIN32) && !defined(__CYGWIN__)
-       /* Make sure open() function will be used with a binary mode. */
-       /* on cygwin, we need something similar, but instead link against */
-       /* a special startup object, binmode.o */
-       _set_fmode(_O_BINARY);
-#endif
 
        /* Need lafe_progname before calling lafe_warnc. */
        if (*argv == NULL)
@@ -693,7 +687,7 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
         */
        if (archive_entry_filetype(entry) == AE_IFREG) {
                if (archive_entry_size(entry) > 0) {
-                       fd = open(srcpath, O_RDONLY);
+                       fd = open(srcpath, O_RDONLY | O_BINARY);
                        if (fd < 0) {
                                lafe_warnc(errno,
                                    "%s: could not open file", srcpath);
@@ -969,11 +963,11 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
 
        if (cpio->option_numeric_uid_gid) {
                /* Format numeric uid/gid for display. */
-               snprintf(uids, sizeof(uids), "%jd",
-                   (intmax_t)archive_entry_uid(entry));
+               snprintf(uids, sizeof(uids), CPIO_FILESIZE_PRINTF,
+                   (CPIO_FILESIZE_TYPE)archive_entry_uid(entry));
                uname = uids;
-               snprintf(gids, sizeof(gids), "%jd",
-                   (intmax_t)archive_entry_gid(entry));
+               snprintf(gids, sizeof(gids), CPIO_FILESIZE_PRINTF,
+                   (CPIO_FILESIZE_TYPE)archive_entry_gid(entry));
                gname = gids;
        } else {
                /* Use uname if it's present, else lookup name from uid. */