From e9fa4c98bb5f084739d3418ade3f0c51e34a0aa1 Mon Sep 17 00:00:00 2001 From: Arne Georg Gleditsch Date: Thu, 5 Jul 2007 00:51:08 +0200 Subject: Rebase tree. --- lib/LXRng/Repo/Plain/File.pm | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/LXRng/Repo/Plain/File.pm (limited to 'lib/LXRng/Repo/Plain/File.pm') diff --git a/lib/LXRng/Repo/Plain/File.pm b/lib/LXRng/Repo/Plain/File.pm new file mode 100644 index 0000000..cf2d6d5 --- /dev/null +++ b/lib/LXRng/Repo/Plain/File.pm @@ -0,0 +1,51 @@ +package LXRng::Repo::Plain::File; + +use strict; + +use base qw(LXRng::Repo::File); +use Fcntl; + +sub new { + my ($class, $name, $path) = @_; + + my @stat = stat($path); + + return undef unless @stat; + + return LXRng::Repo::Plain::Directory->new($name, $path, \@stat) if -d _; + + return bless({name => $name, path => $path, stat => \@stat}, $class); +} + +sub time { + my ($self) = @_; + + return $$self{'stat'}[9]; +} + +sub size { + my ($self) = @_; + + return $$self{'stat'}[7]; +} + +sub phys_path { + my ($self) = @_; + + return $$self{'path'}; +} + +sub revision { + my ($self) = @_; + + return $self->time.'.'.$self->size; +} + +sub handle { + my ($self) = @_; + + sysopen(my $handle, $self->phys_path, O_RDONLY) or die($!); + return $handle; +} + +1; -- cgit v1.2.3