Re: FW: looking for two remote functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Myron Turner wrote:
Tijnema ! wrote:
On 3/10/07, Németh Zoltán <znemeth@xxxxxxxxxxxxxx> wrote:

2007. 03. 10, szombat keltezéssel 12.42-kor Riyadh S. Alshaeiq ezt írta: > Actually if right click on any file or folder on a machine you will see
that
> there are two values (Size on disk & Size). Files and folders are stored
on
> the disk in what is called clusters (a group of disk sectors). Size on
disk
> refers to the amount of cluster allocation a file is taking up, compared
to
> file size which is an actual byte count.
>
> As I mentioned before what I want is a function for getting the result
for
> the Size no for Size on Disk

okay then what about this?


Th

I wrote a small perl script which returns the bytes read when a file is read from the disk and it, too, agrees with the filesize and header sizes. In Windows, the actual filesize is also returned by filesize and stat, not the size on disk (filesize uses stat). Also, in the PHP manual, the fread example uses filesize to set the number of bytes to read:
  ||
Here's the perl script:
    use strict;
    use Fcntl;
    sysopen (FH, "index.htm", O_RDONLY);
    my $buffer;
    my $len = sysread(FH, $buffer, 8192,0);
    print $len,"\n";

If you are really anxious about size you can exec out to this script and get the file size.

--
Sorry the above version of the script was hard-coded for a small test file. Here's the general version:

# get_len.pl
use strict;
use Fcntl;
sysopen (FH, $ARGV[0], O_RDONLY) or die "\n";
my $buffer;
my $bytes_read = 0;
my $offset;
while($bytes_read = sysread(FH, $buffer, 8192, $offset)) {
$offset+=$bytes_read ;
}
print $offset,"\n";

From an exec() you'd call it with the file name:
      perl get_len.pl <filename>
$len = exec("perl get_len.pl $filename");

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux