Added "size" method.

This commit is contained in:
JT Smith 2002-05-22 04:40:30 +00:00
parent 4229c8ff8b
commit a566656055

View file

@ -46,6 +46,7 @@ use WebGUI::Utility;
$attachment->getFilename;
$attachment->getIcon;
$attachment->getPath;
$attachment->getSize;
$attachment->getThumbnail;
$attachment->getType;
$attachment->getURL;
@ -226,6 +227,30 @@ sub getPath {
}
#-------------------------------------------------------------------
=head2 getSize ( )
Returns the size of this file.
=cut
sub getSize {
my ($size);
my (@attributes) = stat($_[0]->{_node}->getPath.'/'.$_[0]->getFilename);
if ($attributes[7] > 1048576) {
$size = round($attributes[7]/1048576);
$size .= 'mb';
} elsif ($attributes[7] > 1024) {
$size = round($attributes[7]/1024);
$size .= 'kb';
} else {
$size = $attributes[7]."b";
}
return $size;
}
#-------------------------------------------------------------------
=head2 getThumbnail ( )