Use rename() if possible in WP_Filesystem_Direct::move(). Props reaperhulk. Fixes #12150

git-svn-id: https://develop.svn.wordpress.org/trunk@13001 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-02-07 02:15:27 +00:00
parent ac720d22ea
commit 8f6db1c96f
1 changed files with 8 additions and 1 deletions

View File

@ -196,11 +196,18 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
function copy($source, $destination, $overwrite = false) {
if ( ! $overwrite && $this->exists($destination) )
return false;
return copy($source, $destination);
}
function move($source, $destination, $overwrite = false) {
//Possible to use rename()?
if ( ! $overwrite && $this->exists($destination) )
return false;
// try using rename first. if that fails (for example, source is read only) try copy
if ( @rename($source, $destination) )
return true;
if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) {
$this->delete($source);
return true;