WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/22/2011 12:04:15 AM (10 years ago)
Author:
dd32
Message:

Optimisations to WP_Filesystem; Pass known information to called functions. Props aldenta (John Ford) for investigation and patch. See #10913

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-direct.php

    r15590 r17525  
    194194    }
    195195
    196     function copy($source, $destination, $overwrite = false) {
     196    function copy($source, $destination, $overwrite = false, $mode = false) {
    197197        if ( ! $overwrite && $this->exists($destination) )
    198198            return false;
    199199
    200         return copy($source, $destination);
     200        $rtval = copy($source, $destination);
     201        if ( $mode )
     202            $this->chmod($destination, $mode);
     203        return $rtval;
    201204    }
    202205
     
    217220    }
    218221
    219     function delete($file, $recursive = false) {
     222    function delete($file, $recursive = false, $type = false) {
    220223        if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
    221224            return false;
    222225        $file = str_replace('\\', '/', $file); //for win32, occasional problems deleteing files otherwise
    223226
    224         if ( $this->is_file($file) )
     227        if ( 'f' == $type || $this->is_file($file) )
    225228            return @unlink($file);
    226229        if ( ! $recursive && $this->is_dir($file) )
     
    234237        if ( is_array($filelist) ) //false if no files, So check first.
    235238            foreach ($filelist as $filename => $fileinfo)
    236                 if ( ! $this->delete($file . $filename, $recursive) )
     239                if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
    237240                    $retval = false;
    238241
Note: See TracChangeset for help on using the changeset viewer.