DaMouse,
Here is a copy of a previous mail for a related problem, with filesizes  and
a little arithmetic you should be able to adapt this to your needs


(Copy of mail to Darren)
Darren,
As others have said, PHP is not really the right tool for client side work
even if the client machine is also the server.  Having said that, the
general style of task you are trying to achieve is frequently tackled by the
use of Recursive functions - functions that call themselves from "within"
themselves. This technique is not by any means limited to PHP, most
languages can do it.   In pseudocode it might look a bit like this



function brain_explode ($directoryname)

do{
get a filename and size and type (from path $directoryname)

if (the file type is of type directory) {
brain_explode;     // call "myself" again before I have finished THIS
iteration
} else {
echo the filename and size
}

} until there are no more files to list

end_of_function.


"until there are no more files to list" might in your instance be "until the
sought after pattern is found"



I dubbed this function brain_explode, plagiarised from Dash`s earlier mail,
because recursive functions, if let loose on really deep tree like
structures of any type (directories, websites, relational databases, linked
lists - whatever) can consume large amounts of memory.  Every time they
recurse (call themselves) a totally new environment and set of variables is
created for another instance of the function to run in while the parent
function (and IT`S parents/grandparents) are still running (of course).  So
a tree structure 5 levels deep will potentially trigger 5 instances of the
function running at the same time.  If large arrays are involved (such as
SQL result sets) your brain could explode.


Hope this helps




----- Original Message -----
From: "DaMouse" <[EMAIL PROTECTED]>
To: "PHP - Win" <[EMAIL PROTECTED]>
Sent: Monday, November 25, 2002 1:58 AM
Subject: [PHP-WIN] measuring space


I want to measure how much space is used by a specific dir and echo it out
e.g.
/home/avalanche = 10mb
/home/damouse = 188kb
/home/pests == 20kb

Ensign Baker
HCO Officer
USS Atlantis



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

Reply via email to