| 1 | package VCS::Cvs::Dir; | ||
| 2 | |||
| 3 | use Carp; | ||
| 4 | use VCS::Cvs; | ||
| 5 | |||
| 6 | @ISA = qw(VCS::Cvs VCS::Dir); | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | |||
| 10 | sub new { | ||
| 11 | my($class, $url) = @_; | ||
| 12 | my $self = $class->init($url); | ||
| 13 | my $path = $self->path; | ||
| 14 | die "$class->new: $path: $!\n" unless -d $path; | ||
| 15 | die "$class->new: $path not a CVS directory: $!\n" | ||
| 16 | unless -d $path . 'CVS'; | ||
| 17 | $self; | ||
| 18 | } | ||
| 19 | |||
| 20 | sub content { | ||
| 21 | my $self = shift; | ||
| 22 | my @return; | ||
| 23 | local *CONTENTS; | ||
| 24 | open(CONTENTS, $self->path . 'CVS/Entries'); | ||
| 25 | while (defined(my $entry = <CONTENTS>)) { | ||
| 26 | my ($type, $path) = $entry =~ m|^([^/]*)/([^/]*)/|; | ||
| 27 | next unless $path; | ||
| 28 | my $new_class = ($type eq 'D') ? 'VCS::Cvs::Dir' : 'VCS::Cvs::File'; | ||
| 29 | push @return, $new_class->new($self->url . $path); | ||
| 30 | } | ||
| 31 | close CONTENTS; | ||
| 32 | return sort { $a->path cmp $b->path } @return; | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; |