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

git-svn-id: http://svn.automattic.com/wordpress/trunk@13001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-07 02:15:27 +00:00
parent 830e5e5316
commit de63fc36f8
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;