function backup_migrate_destination_files::_save_file in Backup and Migrate 8.3
Same name and namespace in other branches
- 8.2 includes/destinations.file.inc \backup_migrate_destination_files::_save_file()
- 6.3 includes/destinations.file.inc \backup_migrate_destination_files::_save_file()
- 7.3 includes/destinations.file.inc \backup_migrate_destination_files::_save_file()
- 7.2 includes/destinations.file.inc \backup_migrate_destination_files::_save_file()
File save destination callback.
Overrides backup_migrate_destination::_save_file
File
- includes/
destinations.file.inc, line 32 - A destination type for saving locally to the server.
Class
- backup_migrate_destination_files
- A destination type for saving locally to the server.
Code
function _save_file($file, $settings) {
if ($this
->confirm_destination() && ($dir = $this
->get_location())) {
$filepath = rtrim($dir, "/") . "/" . $file
->filename();
// Copy the file if there are multiple destinations.
if (count($settings
->get_destinations()) > 1) {
file_unmanaged_copy($file
->filepath(), $filepath);
}
else {
file_unmanaged_move($file
->filepath(), $filepath);
}
// chmod, chown and chgrp the file if needed.
if ($chmod = $this
->settings('chmod')) {
if (!@drupal_chmod($filepath, octdec($chmod))) {
_backup_migrate_message('Unable to set the file mode for: @file', array(
'@file' => $filepath,
), 'error');
}
}
if ($chgrp = $this
->settings('chgrp')) {
if (!@chgrp($filepath, $chgrp)) {
_backup_migrate_message('Unable to set the file group for: @file', array(
'@file' => $filepath,
), 'error');
}
}
return $file;
}
}