Re: [PHP] Directory Size

2003-08-15 Thread Chris Blake
On Fri, 2003-08-15 at 12:36, Marek Kilimajer wrote:
> Are you sure it hangs? It might take a long time to get occupied size. 
> This also depends on the filesystem used, I heard reserfs is best at this.
> 
Well, I thought it was hanging cuz 15 mins went past without any
return...then I figured it had something to do with the fact that its
reading 20Gb of directories and files...

I`m busy investigating some other options :
`du $file -c` seems to workI`ll try playing around a bit and will
report back later...

I`m not sure what you mean re the filsystem type, I`m using MDK, which I
understand uses ext3 (newbie)

Thanks for trying to assist...
-- 
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379

If we men married the women we deserved, we should have a very bad time
of it.
-- Oscar Wilde


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



Re: [PHP] Directory Size

2003-08-15 Thread Marek Kilimajer
Are you sure it hangs? It might take a long time to get occupied size. 
This also depends on the filesystem used, I heard reserfs is best at this.

Chris Blake wrote:
Greetings learned PHP(eople);

Is there a way to calculate the size of directory in PHP ?

I searched php.net and only found ways of opening directories and
reading file sizes
One suggestion on there was to do the following :

$mstrng = shell_exec('du -sc /backup/');
echo '' . $mstrng . '';
When I do that my browser hangs endlesslymind you, it also hangs
when I run du -sc from the command line...
Any pointers muchly appreciated...



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


[PHP] Directory Size

2003-08-15 Thread Chris Blake
Greetings learned PHP(eople);

Is there a way to calculate the size of directory in PHP ?

I searched php.net and only found ways of opening directories and
reading file sizes

One suggestion on there was to do the following :

$mstrng = shell_exec('du -sc /backup/');
echo '' . $mstrng . '';

When I do that my browser hangs endlesslymind you, it also hangs
when I run du -sc from the command line...

Any pointers muchly appreciated...

-- 
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379

Anger kills as surely as the other vices.


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



Re: [PHP] directory size?

2003-04-03 Thread Ernest E Vogelsinger
At 00:40 04.04.2003, Mantas Kriauciunas said:
[snip]
>Hey
>I looked up in the manual but found only 
>Disk_total_space
>Disk_free_space
>
>Is there anything like total_space for directory?
>Or I will have to think of something else?
>Like counting every file size and adding it to total.
>But if there is like 1000 files with directories in the main directory.
>It will take time to count files from all the directories and output
>total size of the main directory.
[snip] 

In case you're on Linux, and may run externals, you could
du -s . (prints kilobytes)
du -s -b (prints bytes)

list($dusage, $dir) = explode(' ', `du -s -b .`);
echo sprintf('The current directory has %d kB (%d bytes)', $dusage / 1024,
$dusage);


-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



[PHP] directory size?

2003-04-03 Thread Mantas Kriauciunas
Hey
I looked up in the manual but found only 
Disk_total_space
Disk_free_space

Is there anything like total_space for directory?
Or I will have to think of something else?
Like counting every file size and adding it to total.
But if there is like 1000 files with directories in the main directory.
It will take time to count files from all the directories and output
total size of the main directory.

I hope I didn't make it sound too confusing:)
Thanks for any help!
Mantas Kriauciunas



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



Re: [PHP] Directory size

2003-02-11 Thread Jeff Pauls
You can try something like this. 

$dir = "dir";

function dirsize($checkdir) {
$dh = opendir($checkdir);
$size = 0;
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..") {
$path = $checkdir."/".$file;
if (is_dir($path))
$size += dirsize($path);
elseif (is_file($path))
$size += filesize($path);
}
closedir($dh);
 $formated_size = $size /1000;
return $formated_size;
}

$getFolderSize = dirsize("/files/personal");


Jeff



- Original Message - 
From: "Marek Kilimajer" <[EMAIL PROTECTED]>
To: "Antti" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, February 03, 2003 4:37 AM
Subject: Re: [PHP] Directory size


> there is no php function for this, you can use unix command du or do it 
> in a loop
> 
> Antti wrote:
> 
> > How do I get the directory size? Suppose there is a function for this.
> >
> > antti
> >
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


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




Re: [PHP] Directory size

2003-02-03 Thread Marek Kilimajer
there is no php function for this, you can use unix command du or do it 
in a loop

Antti wrote:

How do I get the directory size? Suppose there is a function for this.

antti





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




[PHP] Directory size

2003-02-02 Thread Antti
How do I get the directory size? Suppose there is a function for this.

antti


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




[PHP] Directory Size Calculation...trying again!

2002-03-05 Thread Simon H

Tried this earlier but have had no takersis it a no go?  Please read on.

Hello!

I hope someone can help me with this...it's doin' my head in!

Below I have a class I found for finding out directory sizes.  What I have
done is to get the username of each user and their  create a directory path
(based on their username - these directories do exist with subdirs).

This works fine when I restrict the select statement to 1 user, but when
selecting all, it generates an error for (nearly) all the users, namely, the
ones with no contents in their directories.  Thing is, just above the error,
it prints what I want ( I think - haven't check it for accuracy yet).

Any help or ideas on how to achieve this would be most helpful and
appreciated!!

(Win2K, PHP 4.1.1)

The Code
---

display_size(0);
}
else
{
while( $file = readdir($handle) )
{
if($file != '.' and $file != '..')
{
is_dir("$dir/$file") ? 
$this->get_dir_size("$dir/$file", $size) : $size
+= filesize("$dir/$file");
}
}
if ($size < 1)
{
return $this->display_size(0);
$handle ="";
$size = "0";
}
else
{
return $this->display_size($size);
$handle ="";
$size = "0";
}
}
}

// File size calculations - for display.
function display_size($file_size)
{
if($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . " 
Gb";
}
elseif($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . " Mb";
}
elseif($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . " Kb";
}
else
{
$file_size = $file_size . " bytes";
}
return $file_size;
}
}






$sql = "SELECT * FROM FTPUsers";
$result = $dsn2->query( $sql );



if ( DB::isError( $result = $dsn2->query( $sql ) ) )
{
echo DB::errorMessage( $result );
}
else
{
while ( $row = $result->fetchRow( DB_FETCHMODE_ASSOC ) )
{
$dir = "F:/path/to/" . $row[Name] . "";
$d = new DirectoryInfo;
echo "" . $row[Name] . " " . $d->get_dir_size($dir, $size);
}
}


?>
---

Result
---
User1 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User2 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User3 0 bytes

User4 26.33 Mb
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User5 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User6 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13

...
---

Thanks

Simon H


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




[PHP] Directory Size

2002-03-05 Thread Simon H

Hello!

I hope someone can help me with this...it's doin' my head in!

Below I have a class I found for finding out directory sizes.  What I have
done is to get the username of each user and their  create a directory path
(based on their username - these directories do exist with subdirs).

This works fine when I restrict the select statement to 1 user, but when
selecting all, it generates an error for (nearly) all the users, namely, the
ones with no contents in their directories.  Thing is, just above the error,
it prints what I want ( I think - haven't check it for accuracy yet).

Any help or ideas on how to achieve this would be most helpful and
appreciated!!

(Win2K, PHP 4.1.1)

The Code
---

display_size(0);
}
else
{
while( $file = readdir($handle) )
{
if($file != '.' and $file != '..')
{
is_dir("$dir/$file") ? 
$this->get_dir_size("$dir/$file", $size) : $size
+= filesize("$dir/$file");
}
}
if ($size < 1)
{
return $this->display_size(0);
$handle ="";
$size = "0";
}
else
{
return $this->display_size($size);
$handle ="";
$size = "0";
}
}
}

// File size calculations - for display.
function display_size($file_size)
{
if($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . " 
Gb";
}
elseif($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . " Mb";
}
elseif($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . " Kb";
}
else
{
$file_size = $file_size . " bytes";
}
return $file_size;
}
}






$sql = "SELECT * FROM FTPUsers";
$result = $dsn2->query( $sql );



if ( DB::isError( $result = $dsn2->query( $sql ) ) )
{
echo DB::errorMessage( $result );
}
else
{
while ( $row = $result->fetchRow( DB_FETCHMODE_ASSOC ) )
{
$dir = "F:/path/to/" . $row[Name] . "";
$d = new DirectoryInfo;
echo "" . $row[Name] . " " . $d->get_dir_size($dir, $size);
}
}


?>
---

Result
---
User1 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User2 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User3 0 bytes

User4 26.33 Mb
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User5 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13


User6 0 bytes
Warning: OpenDir: Invalid argument (errno 22) in
F:\OBS\WinPartnerWeb\www\partners\pa\obsWebsite\testsize.php on line 13

...
---

Thanks

Simon H


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