Re: FW: looking for two remote functions

From: Date: Sun, 11 Mar 2007 12:21:13 +0000
Subject: Re: FW: looking for two remote functions
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-250223@lists.php.net to get a copy of this message
Myron Turner wrote:
Tijnema ! wrote:
On 3/10/07, Németh Zoltán <znemeth@alterationx.hu> 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/

« previous php.general (#250223) next »