Author: glebius
Date: Thu Oct 21 17:05:15 2010
New Revision: 214137
URL: http://svn.freebsd.org/changeset/base/214137

Log:
  Make it possible to read input from stdin.
  
  Without this change I don't see a way to
  unpack a multivolume archive without wasting
  disk space for a temporary file.

Modified:
  head/usr.bin/unzip/unzip.c

Modified: head/usr.bin/unzip/unzip.c
==============================================================================
--- head/usr.bin/unzip/unzip.c  Thu Oct 21 16:20:48 2010        (r214136)
+++ head/usr.bin/unzip/unzip.c  Thu Oct 21 17:05:15 2010        (r214137)
@@ -859,7 +859,9 @@ unzip(const char *fn)
        int fd, ret;
        uintmax_t total_size, file_count, error_count;
 
-       if ((fd = open(fn, O_RDONLY)) < 0)
+       if (strcmp(fn, "-") == 0)
+               fd = STDIN_FILENO;
+       else if ((fd = open(fn, O_RDONLY)) < 0)
                error("%s", fn);
 
        if ((a = archive_read_new()) == NULL)
@@ -913,7 +915,7 @@ unzip(const char *fn)
        ac(archive_read_close(a));
        (void)archive_read_finish(a);
 
-       if (close(fd) != 0)
+       if (fd != STDIN_FILENO && close(fd) != 0)
                error("%s", fn);
 
        if (t_opt) {
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to