note 75988 added to class.dir

From: Date: Mon, 25 Jun 2007 22:23:29 +0000
Subject: note 75988 added to class.dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-127967@lists.php.net to get a copy of this message
The dir Class, from what I can tell, on a Windows box is not a live image of the directory. When the class is instantiated it takes a snapshot of the directory and then the iterator works off that. I may be wrong, but when I run two processes that look to see if a directory exists, and then deletes the dir when some processing takes place. Deletes from one process do not effect the iteration of the second. To get around this I check that the file exists before doing my processing: $d = dir($dataDir); while (false !== ($entry = $d->read())) if ($entry != '..' && $entry != '.' && file_exists("$dataDir\\$entry")) { // do stuff } $d->close(); I run this as a batch process and can activate it multiple times to process the directory listing in parallel. -CF ---- Server IP: 208.69.120.35 Probable Submitter: 24.250.21.79 ---- Manual Page -- http://www.php.net/manual/en/class.dir.php Edit -- https://master.php.net/note/edit/75988 Del: integrated -- https://master.php.net/note/delete/75988/integrated Del: useless -- https://master.php.net/note/delete/75988/useless Del: bad code -- https://master.php.net/note/delete/75988/bad+code Del: spam -- https://master.php.net/note/delete/75988/spam Del: non-english -- https://master.php.net/note/delete/75988/non-english Del: in docs -- https://master.php.net/note/delete/75988/in+docs Del: other reasons-- https://master.php.net/note/delete/75988 Reject -- https://master.php.net/note/reject/75988 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127967) next »