fix usage without ext/phar
authorMichael Wallner <mike@php.net>
Fri, 18 Jan 2019 16:57:49 +0000 (17:57 +0100)
committerMichael Wallner <mike@php.net>
Fri, 18 Jan 2019 16:57:49 +0000 (17:57 +0100)
bin/pharext
bin/pharext.update
src/pharext/Archive.php
tests/src/pharext/Version.php [deleted symlink]

index 939eeb9dbe41ad2e23437cf0a6f072bd59c91395..363ad33db0375eb4cd6d933af092ccb1ba063203 100755 (executable)
Binary files a/bin/pharext and b/bin/pharext differ
index a8cb44fca725e621f5d8fe1b8e2bd97f1bf8ed06..2d94a20eb3f7a203a20bff594f8489b980da2895 100755 (executable)
Binary files a/bin/pharext.update and b/bin/pharext.update differ
index 072e72178c739b77ca58f2bd3d2a4c6ced61b87e..1955bfada9b7dcd41df92e762ac283c4937f9880 100644 (file)
@@ -144,27 +144,28 @@ class Archive implements ArrayAccess, IteratorAggregate
        }
 
        private function outFd($path, $flags) {
-                       $dirn = dirname($path);
-                       if (!is_dir($dirn) && !@mkdir($dirn, 0777, true)) {
+               $dirn = dirname($path);
+               if (!is_dir($dirn) && !@mkdir($dirn, 0777, true)) {
+                       throw new Exception;
+               }
+               if (!$fd = @fopen($path, "w")) {
+                       throw new Exception;
+               }
+               switch ($flags & self::COMP_FILE_MASK) {
+               case self::COMP_GZ_FILE:
+                       if (!@stream_filter_append($fd, "zlib.inflate")) {
                                throw new Exception;
                        }
-                       if (!$fd = @fopen($path, "w")) {
+                       break;
+               case self::COMP_BZ2_FILE:
+                       if (!@stream_filter_append($fd, "bz2.decompress")) {
                                throw new Exception;
                        }
-                       switch ($flags & self::COMP_FILE_MASK) {
-                       case self::COMP_GZ_FILE:
-                               if (!@stream_filter_append($fd, "zlib.inflate")) {
-                                       throw new Exception;
-                               }
-                               break;
-                       case self::COMP_BZ2_FILE:
-                               if (!@stream_filter_append($fd, "bz2.decompress")) {
-                                       throw new Exception;
-                               }
-                               break;
-                       }
-
+                       break;
+               }
+               return $fd;
        }
+
        private function readVerified($fd, $len) {
                if ($len != strlen($data = fread($fd, $len))) {
                        throw new Exception("Unexpected EOF");
diff --git a/tests/src/pharext/Version.php b/tests/src/pharext/Version.php
deleted file mode 120000 (symlink)
index 39773a5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../src/pharext/Version.php
\ No newline at end of file