note 76806 added to function.rmdir

From: Date: Tue, 31 Jul 2007 13:53:16 +0000
Subject: note 76806 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-129078@lists.php.net to get a copy of this message
Here is a better recursive rmdir function, that relies on php's built-in dir class and doesn't use messy directory changing. <?php function full_rmdir( $dir ) { if ( !is_writable( $dir ) ) { if ( !@chmod( $dir, 0777 ) ) { return FALSE; } } $d = dir( $dir ); while ( FALSE !== ( $entry = $d->read() ) ) { if ( $entry == '.' || $entry == '..' ) { continue; } $entry = $dir . '/' . $entry; if ( is_dir( $entry ) ) { if ( !$this->full_rmdir( $entry ) ) { return FALSE; } continue; } if ( !@unlink( $entry ) ) { $d->close(); return FALSE; } } $d->close(); rmdir( $dir ); return TRUE; } ?> ---- Server IP: 213.250.2.28 Probable Submitter: 212.18.43.58 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/76806 Del: integrated -- https://master.php.net/note/delete/76806/integrated Del: useless -- https://master.php.net/note/delete/76806/useless Del: bad code -- https://master.php.net/note/delete/76806/bad+code Del: spam -- https://master.php.net/note/delete/76806/spam Del: non-english -- https://master.php.net/note/delete/76806/non-english Del: in docs -- https://master.php.net/note/delete/76806/in+docs Del: other reasons-- https://master.php.net/note/delete/76806 Reject -- https://master.php.net/note/reject/76806 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129078) next »