function xmlsitemap_directory_move in XML sitemap 6.2
Same name and namespace in other branches
- 8 xmlsitemap.module \xmlsitemap_directory_move()
- 7.2 xmlsitemap.module \xmlsitemap_directory_move()
- 2.x xmlsitemap.module \xmlsitemap_directory_move()
Move a directory to a new location.
Parameters
$old_dir: A string specifying the filepath or URI of the original directory.
$new_dir: A string specifying the filepath or URI of the new directory.
$replace: Replace behavior when the destination file already exists.
Return value
TRUE if the directory was moved successfully. FALSE otherwise.
1 call to xmlsitemap_directory_move()
- xmlsitemap_sitemap_save in ./
xmlsitemap.module - Save changes to an XML sitemap or add a new XML sitemap.
File
- ./
xmlsitemap.module, line 831 - Main file for the xmlsitemap module.
Code
function xmlsitemap_directory_move($old_dir, $new_dir, $replace = FILE_EXISTS_REPLACE) {
$success = file_check_directory($new_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
if (!is_dir($old_dir) || !is_dir($new_dir) || !$success) {
return FALSE;
}
$files = file_scan_directory($old_dir, '.*');
foreach ($files as $file) {
$file->filepath_new = $new_dir . '/' . $file->basename;
$success &= (bool) file_move($file->filename, $file->filepath_new, $replace);
}
// The remove the directory.
$success &= rmdir($old_dir);
return $success;
}