[ic] Getting File size

Kevin Walsh interchange-users@interchange.redhat.com
Wed Apr 3 09:56:01 2002


> > > 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].
> >
> Why? Give me the light in my head to follow you!
> 
Because any existing code that relies on that tag to return an
unformatted file size will break.  It could be implemented
as a "format=1" argument to the tag.  Until any such mods are
made, it would be just as easy for you to format the result
yourself.

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/