Changeset 7641
- Timestamp:
- 04/13/2008 04:04:57 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-direct.php
r7415 r7641 27 27 } 28 28 function put_contents($file,$contents,$mode=false,$type=''){ 29 $fp=@fopen($file,'w'.$type); 30 if (!$fp) 29 if ( ! ($fp = @fopen($file,'w'.$type)) ) 31 30 return false; 32 31 @fwrite($fp,$contents); … … 37 36 function cwd(){ 38 37 return @getcwd(); 38 } 39 function chdir($dir){ 40 return @chdir($dir); 39 41 } 40 42 function chgrp($file,$group,$recursive=false){ … … 46 48 return @chgrp($file,$group); 47 49 //Is a directory, and we want recursive 50 $file = trailingshashit($file); 48 51 $filelist = $this->dirlist($file); 49 foreach($filelist as $filename) {50 $this->chgrp($file .'/'.$filename,$group,$recursive);51 } 52 foreach($filelist as $filename) 53 $this->chgrp($file . $filename, $group, $recursive); 54 52 55 return true; 53 56 } … … 62 65 return @chmod($file,$mode); 63 66 //Is a directory, and we want recursive 67 $file = trailingshashit($file); 64 68 $filelist = $this->dirlist($file); 65 foreach($filelist as $filename) {66 $this->chmod($file .'/'.$filename,$mode,$recursive);67 } 69 foreach($filelist as $filename) 70 $this->chmod($file . $filename, $mode, $recursive); 71 68 72 return true; 69 73 } … … 83 87 } 84 88 function owner($file){ 85 $owneruid =@fileowner($file);89 $owneruid = @fileowner($file); 86 90 if( ! $owneruid ) 87 91 return false; 88 92 if( !function_exists('posix_getpwuid') ) 89 93 return $owneruid; 90 $ownerarray =posix_getpwuid($owneruid);94 $ownerarray = posix_getpwuid($owneruid); 91 95 return $ownerarray['name']; 92 96 } … … 164 168 } 165 169 function group($file){ 166 $gid =@filegroup($file);170 $gid = @filegroup($file); 167 171 if( ! $gid ) 168 172 return false; 169 173 if( !function_exists('posix_getgrgid') ) 170 174 return $gid; 171 $grouparray =posix_getgrgid($gid);175 $grouparray = posix_getgrgid($gid); 172 176 return $grouparray['name']; 173 177 } … … 180 184 181 185 function move($source,$destination,$overwrite=false){ 182 //Possible to use rename() 186 //Possible to use rename()? 183 187 if( $this->copy($source,$destination,$overwrite) && $this->exists($destination) ){ 184 188 $this->delete($source); … … 189 193 } 190 194 191 function delete($file, $recursive=false){195 function delete($file, $recursive=false){ 192 196 $file = str_replace('\\','/',$file); //for win32, occasional problems deleteing files otherwise 193 197 194 198 if( $this->is_file($file) ) 195 199 return @unlink($file); 196 197 200 if( !$recursive && $this->is_dir($file) ) 198 201 return @rmdir($file); 199 202 200 $filelist = $this->dirlist($file);201 if( ! $filelist )202 return true; //No files exist, Say we've deleted them203 //At this point its a folder, and we're in recursive mode 204 $file = trailingslashit($file); 205 $filelist = $this->dirlist($file, true); 203 206 204 207 $retval = true; 205 foreach($filelist as $filename=>$fileinfo){ 206 if( ! $this->delete($file.'/'.$filename,$recursive) ) 207 $retval = false; 208 } 208 if( is_array($filelist) ) //false if no files, So check first. 209 foreach($filelist as $filename=>$fileinfo) 210 if( ! $this->delete($file . $filename, $recursive) ) 211 $retval = false; 212 209 213 if( ! @rmdir($file) ) 210 214 return false; … … 225 229 226 230 function is_readable($file){ 227 231 return @is_readable($file); 228 232 } 229 233 … … 243 247 } 244 248 245 function touch($file, $time=0,$atime=0){246 if($time ==0)249 function touch($file, $time = 0, $atime = 0){ 250 if($time == 0) 247 251 $time = time(); 248 if($atime ==0)252 if($atime == 0) 249 253 $atime = time(); 250 254 return @touch($file,$time,$atime); 251 255 } 252 256 253 function mkdir($path, $chmod=false,$chown=false,$chgrp=false){257 function mkdir($path, $chmod = false, $chown = false, $chgrp = false){ 254 258 if( ! $chmod) 255 259 $chmod = $this->permission; … … 265 269 266 270 function rmdir($path,$recursive=false){ 271 //Currently unused and untested, Use delete() instead. 267 272 if( ! $recursive ) 268 273 return @rmdir($path); … … 293 298 $struc['name'] = $entry; 294 299 300 if( '.' == $struc['name'] || '..' == $struc['name'] ) 301 continue; //Do not care about these folders. 295 302 if( '.' == $struc['name'][0] && !$incdot) 296 303 continue; … … 308 315 $struc['time'] = date('h:i:s',$struc['lastmodunix']); 309 316 $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; 317 310 318 if ('d' == $struc['type'] ){ 311 $struc['files'] = array(); 312 313 if( $incdot ){ 314 //We're including the doted starts 315 if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder 316 if ($recursive) 317 $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); 318 } 319 } else { //No dots 320 if ($recursive) 321 $struc['files'] = $this->dirlist($path.'/'.$struc['name'],$incdot,$recursive); 322 } 319 if( $recursive ) 320 $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $incdot, $recursive); 321 else 322 $struc['files'] = array(); 323 323 } 324 //File 325 $ret[ $struc['name']] = $struc;324 325 $ret[ $struc['name'] ] = $struc; 326 326 } 327 327 $dir->close();
Note: See TracChangeset
for help on using the changeset viewer.