[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Getting File size
Mike Heins wrote:
>
> Quoting Kyle Cook (kyle@invisio.com):
> > At 12:20 PM 3/28/02, you wrote:
> > >Hi List,
> > >
> > >is anyone so kind to give me the right direction, how can I determine
> > >the size of a file?
> > >
> > >Thanks!
> > >
> > >Joachim
> >
> > Joachim,
> >
> > The perl answer would be:
> >
> > my $size = -s '/path/to/myfile.txt';
> >
>
> Or in ITL:
>
> [file-info size=1 file="relative/path/to/myfile"]
>
> That tag is in the UI, so you would need to relocate it if not
> using the UI.
Thank you a lot! But I think
if($opt->{size}) {
return $stat[7];
}
should be as
if($opt->{size}) {
return $stat[7] < 1024
? $stat[7]
: ( $stat[7] < 1024 * 1024
? sprintf ("%.2fK", $stat[7] / 1024)
: sprintf ("%.2fM", $stat[7] / 1024 / 1024)
);
}
to get the file size with K or M. What do you think?
Joachim
--
Hans-Joachim Leidinger | Dipl.-Phys.Ing. Entwicklung eCommerce
[leidinger@bpanet.de]
Black Point Arts Internet Solutions GmbH
http://www.bpanet.de