Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jul 2010 20:54:44 GMT
From:      Julien Laffaye <jlaffaye@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 181393 for review
Message-ID:  <201007232054.o6NKsiY3024550@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@181393?ac=10

Change 181393 by jlaffaye@jlaffaye-chulak on 2010/07/23 20:53:46

	Read from stdin if filename is '-'.

Affected files ...

.. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#5 edit

Differences ...

==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#5 (text+ko) ====

@@ -64,6 +64,7 @@
 	struct archive *a = NULL;
 	struct archive_entry *entry;
 	const char *pathname;
+	int fd = 0;
 	int retcode = 0;
 
 	a = archive_read_new();
@@ -80,7 +81,16 @@
 	    /* TODO: add support */
 	    return (1);
 	} else {
-	    if (archive_read_open_filename(a, fname, 10240) != ARCHIVE_OK) {
+	    if (strcmp(fname, "-") == 0)
+		fd = fileno(stdin);
+	    else {
+		if ((fd = open(fname, O_RDONLY)) == -1) {
+		    warn("open(%s)", fname);
+		    return (1);
+		}
+	    }
+
+	    if (archive_read_open_fd(a, fd, 10240) != ARCHIVE_OK) {
 		warnx("Can not open '%s' archive: %s", fname,
 		      archive_error_string(a));
 		retcode = 1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007232054.o6NKsiY3024550>