You can try directoryIterator and recursiveDirectoryIterator in php5.
I don't know if they are more faster than your solution (it seems to me that these extension are written in php, not in C, but portage to C is in todo list), but they do exactly the same thing than your class.


Is it really a good thing to reimplement a builtin solution ?

Fred

Wouter van Vliet wrote:

Howdy,

I've written some, kinda coolish, class that reads directories
recursively with some simple calls. Yihaaa, .. (but I'm not the only
one who has done that, I guess :P). Anyway, during the process of
traversing a directory it checks to see if the "something" that was
found is either a directory or a file, based on that it will do some
things. Fine, works.

But, now that I've got a directory with about 800 files to read I
noticed that it takes the poor script almost two seconds to find the
correct type of all the "somethings". In fact, I timed it on a steady
1.71.

I've tried to use filetype() on the "something", but that took even
longer - while looping through the directory without any checks
finishes in 0.01 seconds.

Now, for the question: does anybody know an alternative method on
checking whether a "something" is either file or directory?

Wouter

(this time, I'm on a Windows XP machine running PHP5 - just tested the
same thing on Linux and PHP 4.3.8 and came out on 0.63 secs, ..)


-- =================================================================== Frederic HARDY Email: [EMAIL PROTECTED] HEXANET SARL URL: http://www.hexanet.fr/ ZAC Les Charmilles Tel: +33 (0)3 26 79 30 05 3, allée Thierry Sabine Direct: +33 (0)3 26 61 77 84 BP 202 - 51686 REIMS CEDEX 2 FRANCE ===================================================================

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to