From: Michael Wallner Date: Fri, 18 Jan 2019 16:57:49 +0000 (+0100) Subject: fix usage without ext/phar X-Git-Tag: v4.1.2~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ca052b5308bb8c4d07458308fae1adde522a637f;p=pharext%2Fpharext fix usage without ext/phar --- diff --git a/bin/pharext b/bin/pharext index 939eeb9..363ad33 100755 Binary files a/bin/pharext and b/bin/pharext differ diff --git a/bin/pharext.update b/bin/pharext.update index a8cb44f..2d94a20 100755 Binary files a/bin/pharext.update and b/bin/pharext.update differ diff --git a/src/pharext/Archive.php b/src/pharext/Archive.php index 072e721..1955bfa 100644 --- a/src/pharext/Archive.php +++ b/src/pharext/Archive.php @@ -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 index 39773a5..0000000 --- a/tests/src/pharext/Version.php +++ /dev/null @@ -1 +0,0 @@ -../../../src/pharext/Version.php \ No newline at end of file