Changeset 17525
- Timestamp:
- 03/22/2011 12:04:15 AM (14 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-direct.php
r15590 r17525 194 194 } 195 195 196 function copy($source, $destination, $overwrite = false ) {196 function copy($source, $destination, $overwrite = false, $mode = false) { 197 197 if ( ! $overwrite && $this->exists($destination) ) 198 198 return false; 199 199 200 return copy($source, $destination); 200 $rtval = copy($source, $destination); 201 if ( $mode ) 202 $this->chmod($destination, $mode); 203 return $rtval; 201 204 } 202 205 … … 217 220 } 218 221 219 function delete($file, $recursive = false ) {222 function delete($file, $recursive = false, $type = false) { 220 223 if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. 221 224 return false; 222 225 $file = str_replace('\\', '/', $file); //for win32, occasional problems deleteing files otherwise 223 226 224 if ( $this->is_file($file) )227 if ( 'f' == $type || $this->is_file($file) ) 225 228 return @unlink($file); 226 229 if ( ! $recursive && $this->is_dir($file) ) … … 234 237 if ( is_array($filelist) ) //false if no files, So check first. 235 238 foreach ($filelist as $filename => $fileinfo) 236 if ( ! $this->delete($file . $filename, $recursive ) )239 if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) 237 240 $retval = false; 238 241 -
trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
r15086 r17525 184 184 return $dir[$file]['group']; 185 185 } 186 function copy($source, $destination, $overwrite = false 186 function copy($source, $destination, $overwrite = false, $mode = false) { 187 187 if ( ! $overwrite && $this->exists($destination) ) 188 188 return false; … … 190 190 if ( false === $content) 191 191 return false; 192 return $this->put_contents($destination, $content );192 return $this->put_contents($destination, $content, $mode); 193 193 } 194 194 function move($source, $destination, $overwrite = false) { … … 196 196 } 197 197 198 function delete($file, $recursive = false 198 function delete($file, $recursive = false, $type = false) { 199 199 if ( empty($file) ) 200 200 return false; 201 if ( $this->is_file($file) )201 if ( 'f' == $type || $this->is_file($file) ) 202 202 return @ftp_delete($this->link, $file); 203 203 if ( !$recursive ) … … 207 207 if ( !empty($filelist) ) 208 208 foreach ( $filelist as $delete_file ) 209 $this->delete( trailingslashit($file) . $delete_file['name'], $recursive );209 $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); 210 210 return @ftp_rmdir($this->link, $file); 211 211 } -
trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r13770 r17525 194 194 } 195 195 196 function copy($source, $destination, $overwrite = false 196 function copy($source, $destination, $overwrite = false, $mode = false) { 197 197 if ( ! $overwrite && $this->exists($destination) ) 198 198 return false; … … 202 202 return false; 203 203 204 return $this->put_contents($destination, $content );204 return $this->put_contents($destination, $content, $mode); 205 205 } 206 206 … … 209 209 } 210 210 211 function delete($file, $recursive = false 211 function delete($file, $recursive = false, $type = false) { 212 212 if ( empty($file) ) 213 213 return false; 214 if ( $this->is_file($file) )214 if ( 'f' == $type || $this->is_file($file) ) 215 215 return $this->ftp->delete($file); 216 216 if ( !$recursive ) -
trunk/wp-admin/includes/class-wp-filesystem-ssh2.php
r13770 r17525 239 239 } 240 240 241 function copy($source, $destination, $overwrite = false 241 function copy($source, $destination, $overwrite = false, $mode = false) { 242 242 if ( ! $overwrite && $this->exists($destination) ) 243 243 return false; … … 245 245 if ( false === $content) 246 246 return false; 247 return $this->put_contents($destination, $content );247 return $this->put_contents($destination, $content, $mode); 248 248 } 249 249 … … 252 252 } 253 253 254 function delete($file, $recursive = false ) {255 if ( $this->is_file($file) )254 function delete($file, $recursive = false, $type = false) { 255 if ( 'f' == $type || $this->is_file($file) ) 256 256 return ssh2_sftp_unlink($this->sftp_link, $file); 257 257 if ( ! $recursive ) … … 260 260 if ( is_array($filelist) ) { 261 261 foreach ( $filelist as $filename => $fileinfo) { 262 $this->delete($file . '/' . $filename, $recursive );262 $this->delete($file . '/' . $filename, $recursive, $fileinfo['type']); 263 263 } 264 264 } -
trunk/wp-admin/includes/file.php
r17200 r17525 81 81 $siteurl = get_option( 'siteurl' ); 82 82 if ( $home != '' && $home != $siteurl ) { 83 84 85 83 $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */ 84 $pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home); 85 $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos); 86 86 $home_path = trailingslashit( $home_path ); 87 87 } else { … … 774 774 foreach ( (array) $dirlist as $filename => $fileinfo ) { 775 775 if ( 'f' == $fileinfo['type'] ) { 776 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true ) ) {776 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { 777 777 // If copy failed, chmod file to 0644 and try again. 778 778 $wp_filesystem->chmod($to . $filename, 0644); 779 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true ) )779 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) 780 780 return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename); 781 781 } 782 $wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE);783 782 } elseif ( 'd' == $fileinfo['type'] ) { 784 783 if ( !$wp_filesystem->is_dir($to . $filename) ) {
Note: See TracChangeset
for help on using the changeset viewer.