[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Getting File size
> > > >is anyone so kind to give me the right direction, how can I determine
> > > >the size of a file?
> > > >
> > > 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?
>
The tag could be modified to do that, but I think its probably
better that you do it yourself with a [calc].
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin@cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/