1 installer.manager.inc | installer_manager_file_get($url) |
Copies a file from the specified URL to the temporary directory for updates.
Returns the local path if the file has already been downloaded.
Parameters
$url: The URL of the file on the server.
Return value
string: Path to local file.
Related topics
File
- core/
modules/ installer/ installer.manager.inc, line 1061 - Administrative screens and processing functions of the Installer module.
Code
function installer_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 backdrop_realpath($url);
}
// Check the cache and download the file if needed.
$cache_directory = _installer_manager_cache_directory();
$local = $cache_directory . '/' . backdrop_basename($parsed_url['path']);
installer_delete_file_if_stale($local);
if (!file_exists($local)) {
return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
}
else {
return $local;
}
}