Re: FW: looking for two remote functions
| From: | Tijnema ! | Date: | Sun, 11 Mar 2007 12:27:24 +0000 |
| Subject: | Re: FW: looking for two remote functions | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250224@lists.php.net to get a copy of this message | ||
On 3/11/07, Myron Turner <turnermm02@shaw.ca> wrote:
Myron Turner wrote: Tijnema ! wrote:I'm not very familiar with PERL, so will this work with remote files? As it seems that you are just reading from local hard drive... Tijnema _____________________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:On 3/10/07, Németh Zoltán <znemeth@alterationx.hu> wrote:Actually if right click on any file or folder on a machine you2007. 03. 10, szombat keltezéssel 12.42-kor Riyadh S. Alshaeiq ezt írta:there are two values (Size on disk & Size). Files and folders arewill see thatthe disk in what is called clusters (a group of disk sectors).stored onrefers to the amount of cluster allocation a file is taking up,Size on diskfile size which is an actual byte count. As I mentioned before what I want is a function for getting thecompared tothe Size no for Size on Diskresult forokay then what about this?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/