File: Dir.pm

package info (click to toggle)
libvcs-perl 0.14-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 264 kB
  • ctags: 282
  • sloc: perl: 1,083; makefile: 567
file content (35 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (2)
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
package VCS::Cvs::Dir;

use Carp;
use VCS::Cvs;

@ISA = qw(VCS::Cvs VCS::Dir);

use strict;

sub new {
    my($class, $url) = @_;
    my $self = $class->init($url);
    my $path = $self->path;
    die "$class->new: $path: $!\n" unless -d $path;
    die "$class->new: $path not a CVS directory: $!\n"
        unless -d $path . 'CVS';
    $self;
}

sub content {
    my $self = shift;
    my @return;
    local *CONTENTS;
    open(CONTENTS, $self->path . 'CVS/Entries');
    while (defined(my $entry = <CONTENTS>)) {
        my ($type, $path) = $entry =~ m|^([^/]*)/([^/]*)/|;
        next unless $path;
        my $new_class = ($type eq 'D') ? 'VCS::Cvs::Dir' : 'VCS::Cvs::File';
        push @return, $new_class->new($self->url . $path);
    }
    close CONTENTS;
    return sort { $a->path cmp $b->path } @return;
}

1;