pharext\Archive::extractTo PHP Method

extractTo() public method

public extractTo ( $dir )
    function extractTo($dir)
    {
        if ((string) $this->extracted == (string) $dir) {
            return $this->extracted;
        }
        foreach ($this->manifest["entries"] as $file => $entry) {
            fseek($this->fd, $this->manifest["offset"] + $entry["offset"]);
            $path = "{$dir}/{$file}";
            $copy = stream_copy_to_stream($this->fd, $this->outFd($path, $entry["flags"]), $entry["csize"]);
            if ($entry["osize"] != $copy) {
                throw new Exception("Copied '{$copy}' of '{$file}', expected '{$entry["osize"]}' from '{$entry["csize"]}");
            }
            $crc = hexdec(hash_file("crc32b", $path));
            if ($crc !== $entry["crc32"]) {
                throw new Exception("CRC mismatch of '{$file}': '{$crc}' != '{$entry["crc32"]}");
            }
            chmod($path, $entry["flags"] & self::PERM_FILE_MASK);
            touch($path, $entry["stamp"]);
        }
        return $this->extracted = $dir;
    }