- Timestamp:
- 09/09/2013 02:54:50 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-direct.php
r25304 r25305 26 26 $this->errors = new WP_Error(); 27 27 } 28 28 29 /** 29 30 * connect filesystem. … … 34 35 return true; 35 36 } 37 36 38 /** 37 39 * Reads entire file into a string … … 43 45 return @file_get_contents($file); 44 46 } 47 45 48 /** 46 49 * Reads entire file into an array … … 52 55 return @file($file); 53 56 } 57 54 58 /** 55 59 * Write a string to a file … … 76 80 return true; 77 81 } 82 78 83 /** 79 84 * Gets the current working directory … … 84 89 return @getcwd(); 85 90 } 91 86 92 /** 87 93 * Change directory … … 93 99 return @chdir($dir); 94 100 } 101 95 102 /** 96 103 * Changes file group … … 108 115 if ( ! $this->is_dir($file) ) 109 116 return @chgrp($file, $group); 110 // Is a directory, and we want recursive117 // Is a directory, and we want recursive 111 118 $file = trailingslashit($file); 112 119 $filelist = $this->dirlist($file); … … 116 123 return true; 117 124 } 125 118 126 /** 119 127 * Changes filesystem permissions … … 136 144 if ( ! $recursive || ! $this->is_dir($file) ) 137 145 return @chmod($file, $mode); 138 // Is a directory, and we want recursive146 // Is a directory, and we want recursive 139 147 $file = trailingslashit($file); 140 148 $filelist = $this->dirlist($file); … … 144 152 return true; 145 153 } 154 146 155 /** 147 156 * Changes file owner … … 159 168 if ( ! $this->is_dir($file) ) 160 169 return @chown($file, $owner); 161 // Is a directory, and we want recursive170 // Is a directory, and we want recursive 162 171 $filelist = $this->dirlist($file); 163 172 foreach ($filelist as $filename) { … … 166 175 return true; 167 176 } 177 168 178 /** 169 179 * Gets file owner … … 181 191 return $ownerarray['name']; 182 192 } 193 183 194 /** 184 195 * Gets file permissions … … 192 203 return substr(decoct(@fileperms($file)),3); 193 204 } 205 194 206 function group($file) { 195 207 $gid = @filegroup($file); … … 229 241 230 242 function delete($file, $recursive = false, $type = false) { 231 if ( empty( $file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.232 return false; 233 $file = str_replace( '\\', '/', $file); //for win32, occasional problems deleting files otherwise243 if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. 244 return false; 245 $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise 234 246 235 247 if ( 'f' == $type || $this->is_file($file) ) … … 238 250 return @rmdir($file); 239 251 240 // At this point it's a folder, and we're in recursive mode252 // At this point it's a folder, and we're in recursive mode 241 253 $file = trailingslashit($file); 242 254 $filelist = $this->dirlist($file, true); 243 255 244 256 $retval = true; 245 if ( is_array( $filelist) ) //false if no files, So check first.246 foreach ( $filelist as $filename => $fileinfo)257 if ( is_array( $filelist ) ) { 258 foreach ( $filelist as $filename => $fileinfo ) { 247 259 if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) 248 260 $retval = false; 261 } 262 } 249 263 250 264 if ( file_exists($file) && ! @rmdir($file) ) 251 265 $retval = false; 266 252 267 return $retval; 253 268 } … … 280 295 return @filemtime($file); 281 296 } 297 282 298 function size($file) { 283 299 return @filesize($file);
Note: See TracChangeset
for help on using the changeset viewer.