Update of /cvsroot/sandweb/sandweb/lib/SandWeb
In directory usw-pr-cvs1:/tmp/cvs-serv9142
Modified Files:
File.pm
Log Message:
removed all the code duplication.
object orientation kicks ass :)
Index: File.pm
===================================================================
RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- File.pm 2001/11/22 01:40:25 1.9
+++ File.pm 2001/11/22 01:53:11 1.10
@@ -9,7 +9,18 @@
my %args = @_;
+ my $filename = $args{'filename'};
+ my $location = $args{'location'};
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks)
+ = stat("$location/$filename");
+
my $self = bless {
- 'filename' => $args{'filename'},
- 'location' => $args{'location'},
+ 'filename' => $filename,
+ 'location' => $location,
+ 'mode' => $mode,
+ 'uid' => $uid,
+ 'gid' => $gid,
+ 'size' => $size,
+ 'mtime' => $mtime,
}, $class;
@@ -19,23 +30,10 @@
sub get_owner {
my $self = shift;
- my $location = $self->{'location'};
- my $filename = $self->{'filename'};
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat("$location/$filename");
-
- my $owner = $uid;
- return $owner;
+ return $self->{'owner'};
}
sub get_group {
my $self = shift;
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat("$location/$filename");
-
- my $group = $gid;
- return $group;
+ return $self->{'group'};
}
@@ -52,8 +50,5 @@
sub get_permissions {
my $self = shift;
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat("$location/$filename");
-
+ my $mode = $self->{'mode'};
return $mode & 0777;
}
@@ -61,5 +56,4 @@
sub get_file_type {
my $self = shift;
-
my $location = $self->{'location'};
my $filename = $self->{'filename'};
@@ -82,26 +76,10 @@
sub get_size {
my $self = shift;
-
- my $location = $self->{'location'};
- my $filename = $self->{'filename'};
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat("$location/$filename");
-
- return $size;
+ return $self->{'size'};
}
sub get_age {
my $self = shift;
-
- my $location = $self->{'location'};
- my $filename = $self->{'filename'};
-
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat("$location/$filename");
-
- return $mtime;
+ return $self->{'mtime'};
}
|