update_manager_file_get
- Versions
- 7
update_manager_file_get($url)
Copies a file from $url to the temporary directory for updates.
If the file has already been downloaded, returns the the local path.
Parameters
$url The URL of the file on the server.
Return value
string Path to local file.
Related topics
Code
modules/update/update.manager.inc, line 720
<?php
function update_manager_file_get($url) {
$parsed_url = parse_url($url);
$remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
if (!in_array($parsed_url['scheme'], $remote_schemes)) {
// This is a local file, just return the path.
return drupal_realpath($url);
}
// Check the cache and download the file if needed.
$local = 'temporary://update-cache/' . basename($parsed_url['path']);
$cache_directory = DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-cache/';
if (!file_exists($cache_directory)) {
mkdir($cache_directory);
}
if (!file_exists($local)) {
return system_retrieve_file($url, $local);
}
else {
return $local;
}
}
?>Login or register to post comments 