function download()
{
$versionInfo = VersionCheck::getLatestVersion();
if (!$versionInfo) {
$application = PKPApplication::getApplication();
printf("Failed to load version info from %s\n", $application->getVersionDescriptorUrl());
exit(1);
}
$download = $versionInfo['package'];
$outFile = basename($download);
printf("Download %s: %s\n", $type, $download);
printf("File will be saved to: %s\n", $outFile);
if (!$this->promptContinue()) {
exit(0);
}
$out = fopen($outFile, 'wb');
if (!$out) {
printf("Failed to open %s for writing\n", $outFile);
exit(1);
}
$in = fopen($download, 'rb');
if (!$in) {
printf("Failed to open %s for reading\n", $download);
fclose($out);
exit(1);
}
printf('Downloading file...');
while (($data = fread($in, 4096)) !== '') {
printf('.');
fwrite($out, $data);
}
printf("done\n");
fclose($in);
fclose($out);
}