aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Repo/Plain/File.pm
blob: cf2d6d53180e54218fdc620d43f4b690280200c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;