public function getFile()
    {
        if (null === $this->file) {
            unlink($this->file = tempnam(sys_get_temp_dir(), 'upd'));
            mkdir($this->file);

            $this->file .= DIRECTORY_SEPARATOR . $this->name;

            $in = new SplFileObject($this->url, 'rb', false);
            $out = new SplFileObject($this->file, 'wb', false);

            while (false === $in->eof()) {
                $out->fwrite($in->fgets());
            }

            unset($in, $out);

            if ($this->publicKey) {
                $in = new SplFileObject($this->publicKey, 'r', false);
                $out = new SplFileObject($this->file . '.pubkey', 'w', false);

                while (false === $in->eof()) {
                    $out->fwrite($in->fgets());
                }

                unset($in, $out);
            }

            if ($this->sha1 !== ($sha1 = sha1_file($this->file))) {
                $this->deleteFile();

                throw FileException::create(
                    'Mismatch of the SHA1 checksum (%s) of the downloaded file (%s).',
                    $this->sha1,
                    $sha1
                );
            }

            // double check
            try {
                new Phar($this->file);
            } catch (UnexpectedValueException $exception) {
                $this->deleteFile();

                throw $exception;
            }
        }

        return $this->file;
    }