| 1 | package File::Descriptions; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | #========================================================================= | ||||||||||||
| 7 | # Require | ||||||||||||
| 8 | #------------------------------------------------------------------------- | ||||||||||||
| 9 | # Modules also used | ||||||||||||
| 10 | # require Tie::CPHash; | ||||||||||||
| 11 | |||||||||||||
| 12 | 1 | require Exporter; | |||||||||||
| 13 | 1 | require AutoLoader; | |||||||||||
| 14 | |||||||||||||
| 15 | 1 | @ISA = qw(Exporter AutoLoader); | |||||||||||
| 16 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||
| 17 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||
| 18 | # Do not simply export all your public functions/methods/constants. | ||||||||||||
| 19 | 1 | @EXPORT = qw( | |||||||||||
| 20 | |||||||||||||
| 21 | ); | ||||||||||||
| 22 | 1 | $VERSION = '0.03'; | |||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | # Preloaded methods go here. | ||||||||||||
| 26 | |||||||||||||
| 27 | #========================================================================= | ||||||||||||
| 28 | # Methods | ||||||||||||
| 29 | #------------------------------------------------------------------------- | ||||||||||||
| 30 | # Constructor | ||||||||||||
| 31 | |||||||||||||
| 32 | sub new | ||||||||||||
| 33 | 1 | ▶ | { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 34 | 1 | my $class = shift; | |||||||||||
| 35 | 1 | my $self = {}; | |||||||||||
| 36 | 1 | ▶ | $self->{dir} = $_[0] || '.'; | ||||||||||
|
Condition50%1/2
$_[0] || '.'
MC/DC0%0/1
$_[0] || '.'
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||
| 37 | 1 | %{$self->{desc}} = (); | |||||||||||
| 38 | # tie %{$self->{desc}},'Tie::CPHash'; | ||||||||||||
| 39 | 1 | bless $self, $class; | |||||||||||
| 40 | 1 | $self; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | #========================================================================= | ||||||||||||
| 44 | # Methods | ||||||||||||
| 45 | #------------------------------------------------------------------------- | ||||||||||||
| 46 | # Destructor | ||||||||||||
| 47 | |||||||||||||
| 48 | sub DESTROY | ||||||||||||
| 49 | 1 | ▶ | { | ||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||
| 50 | 1 | my $self = shift; | |||||||||||
| 51 | # untie %{$self->{desc}}; | ||||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | #========================================================================= | ||||||||||||
| 55 | # Methods | ||||||||||||
| 56 | #------------------------------------------------------------------------- | ||||||||||||
| 57 | # gethash($directory) | ||||||||||||
| 58 | |||||||||||||
| 59 | sub gethash | ||||||||||||
| 60 | 4 | ▶ | { | ||||||||||
|
Subroutine
gethash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 61 | 4 | my $self = shift; | |||||||||||
| 62 | 4 | ▶ | $self->{dir} = $_[0] if $_[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | # Make something to cache dir's ... | ||||||||||||
| 65 | 4 | %{$self->{desc}->{ $self->{dir} }} = (); | |||||||||||
| 66 | |||||||||||||
| 67 | # get file descriptions on $self->dir | ||||||||||||
| 68 | 4 | $self->{desc}->{ $self->{dir} }->{'test'} = 'okay'; | |||||||||||
| 69 | |||||||||||||
| 70 | 4 | $self->try_simtelnet(); | |||||||||||
| 71 | 4 | $self->try_debian(); | |||||||||||
| 72 | 4 | $self->try_freebsd(); | |||||||||||
| 73 | |||||||||||||
| 74 | # return the array... | ||||||||||||
| 75 | 4 | return %{$self->{desc}->{ $self->{dir} }}; | |||||||||||
| 76 | } | ||||||||||||
| 77 | |||||||||||||
| 78 | sub directory | ||||||||||||
| 79 | 14 | ▶ | { | ||||||||||
|
Subroutine
directory: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 80 | 14 | my $self = shift; | |||||||||||
| 81 | |||||||||||||
| 82 | 14 | return $self->{dir}; | |||||||||||
| 83 | |||||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | sub try_simtelnet | ||||||||||||
| 87 | 4 | ▶ | { | ||||||||||
|
Subroutine
try_simtelnet: called CC=18 SCAR=29.1
Pod
undocumented
| |||||||||||||
| 88 | 4 | my $self = shift; | |||||||||||
| 89 | 4 | my $current_dir = $self->directory; | |||||||||||
| 90 | |||||||||||||
| 91 | 4 | ▶ | $current_dir.='/' unless ($current_dir =~ /\/$/); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 92 | |||||||||||||
| 93 | 4 | my $current_file=$current_dir.'dirs.txt'; | |||||||||||
| 94 | |||||||||||||
| 95 | 4 | ▶ | if ( -f $current_file ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 96 | 1 | ▶ | if ( -r _ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 97 | 1 | ▶ | if (open(DESCRIPTOR,"<".$current_file)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 98 | # ok, we got the dirs, checking: | ||||||||||||
| 99 | 1 | my $line = <DESCRIPTOR>; | |||||||||||
| 100 | 1 | ▶ | if ($line =~ /simtel/i) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 101 | # checked it's a simtel file... | ||||||||||||
| 102 | 1 | my $got_the_blank = 0; | |||||||||||
| 103 | 1 | ▶ | while (<DESCRIPTOR>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 104 | 178 | chomp; | |||||||||||
| 105 | # chomping a probable \r also... | ||||||||||||
| 106 | 178 | chomp; | |||||||||||
| 107 | 178 | ▶ | $got_the_blank++ if ($_ eq ''); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 108 | 178 | ▶ | last if ($got_the_blank > 1); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 109 | 177 | ▶ | if ($got_the_blank) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 110 | # start picking up the passangers | ||||||||||||
| 111 | 176 | my $file; | |||||||||||
| 112 | my $desc; | ||||||||||||
| 113 | 176 | ($file,$desc) = ($_ =~ /^(\S+)\s+(.+)$/); | |||||||||||
| 114 | 176 | $self->{desc}->{ $self->{dir} }->{$file} = $desc; | |||||||||||
| 115 | } | ||||||||||||
| 116 | } | ||||||||||||
| 117 | } | ||||||||||||
| 118 | 1 | close(DESCRIPTOR); | |||||||||||
| 119 | } | ||||||||||||
| 120 | } | ||||||||||||
| 121 | } | ||||||||||||
| 122 | |||||||||||||
| 123 | 4 | my $current_file=$current_dir.'00_index.txt'; | |||||||||||
| 124 | |||||||||||||
| 125 | |||||||||||||
| 126 | 4 | ▶ | if ( -f $current_file ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 127 | 1 | ▶ | if ( -r _ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 128 | 1 | ▶ | if (open(DESCRIPTOR,"<".$current_file)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 129 | # ok, we got the dirs, checking: | ||||||||||||
| 130 | 1 | my $line = <DESCRIPTOR>; | |||||||||||
| 131 | 1 | ▶ | if ($line =~ /^NOTE/i) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 132 | # checked it's a simtel file... | ||||||||||||
| 133 | 1 | my $got_the_blank = 0; | |||||||||||
| 134 | 1 | ▶ | while (<DESCRIPTOR>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 135 | 20 | chomp; | |||||||||||
| 136 | # chomping a probable \r also... | ||||||||||||
| 137 | 20 | chomp; | |||||||||||
| 138 | 20 | ▶ | $got_the_blank++ if ($_ eq ''); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 139 | 20 | ▶ | last if ($got_the_blank > 2); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 140 | 20 | ▶ | if ($got_the_blank == 2) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 141 | # skip rubble | ||||||||||||
| 142 | 16 | <DESCRIPTOR>; | |||||||||||
| 143 | 16 | <DESCRIPTOR>; | |||||||||||
| 144 | 16 | <DESCRIPTOR>; | |||||||||||
| 145 | # start picking up the passangers | ||||||||||||
| 146 | 16 | my $file; | |||||||||||
| 147 | my $desc; | ||||||||||||
| 148 | 16 | ($file,$desc) = ($_ =~ /^(\S+)\s+\S+\s+\S+\s+\S+\s+(.+)$/); | |||||||||||
| 149 | 16 | $self->{desc}->{ $self->{dir} }->{$file} = $desc; | |||||||||||
| 150 | } | ||||||||||||
| 151 | } | ||||||||||||
| 152 | } | ||||||||||||
| 153 | 1 | close(DESCRIPTOR); | |||||||||||
| 154 | } | ||||||||||||
| 155 | } | ||||||||||||
| 156 | } | ||||||||||||
| 157 | } | ||||||||||||
| 158 | |||||||||||||
| 159 | sub try_debian | ||||||||||||
| 160 | 4 | ▶ | { | ||||||||||
|
Subroutine
try_debian: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||
| 161 | 4 | my $self = shift; | |||||||||||
| 162 | 4 | my $current_dir = $self->directory; | |||||||||||
| 163 | |||||||||||||
| 164 | 4 | ▶ | $current_dir.='/' unless ($current_dir =~ /\/$/); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 165 | |||||||||||||
| 166 | 4 | my $current_file=$current_dir.'../'.'Packages'; | |||||||||||
| 167 | |||||||||||||
| 168 | 4 | ▶ | if ( -f $current_file ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 169 | 1 | ▶ | if ( -r _ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 170 | 1 | ▶ | if (open(DESCRIPTOR,"<".$current_file)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 171 | # ok, we got the dirs | ||||||||||||
| 172 | 1 | my $got_the_file = 0; | |||||||||||
| 173 | 1 | my $file; | |||||||||||
| 174 | my $desc; | ||||||||||||
| 175 | 1 | ▶ | while (<DESCRIPTOR>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 176 | 33 | chomp; | |||||||||||
| 177 | # chomping a probable \r also... | ||||||||||||
| 178 | 33 | chomp; | |||||||||||
| 179 | # start picking up the passangers | ||||||||||||
| 180 | 33 | ▶ | if ($_ =~ /^Filename:/i) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 181 | 2 | ($file) = ($_ =~ /\/([^\/]*?)$/); | |||||||||||
| 182 | 2 | ▶ | if ($file ne '') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 183 | 2 | my $current_test = $current_dir.$file; | |||||||||||
| 184 | 2 | ▶ | if ( -e $current_test ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 185 | 1 | $got_the_file++; | |||||||||||
| 186 | } | ||||||||||||
| 187 | } | ||||||||||||
| 188 | } | ||||||||||||
| 189 | 33 | ▶ | if ($_ =~ /Description:/i) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 190 | 2 | ($desc) = ($_ =~ /^\S+:\s+(.+)$/); | |||||||||||
| 191 | 2 | $got_the_file++; | |||||||||||
| 192 | } | ||||||||||||
| 193 | 33 | ▶ | if ($got_the_file == 2) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 194 | 5 | $self->{desc}->{ $self->{dir} }->{$file} = $desc; | |||||||||||
| 195 | } | ||||||||||||
| 196 | 33 | ▶ | if ($_ eq '') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 197 | 1 | $got_the_file = 0; | |||||||||||
| 198 | } | ||||||||||||
| 199 | } | ||||||||||||
| 200 | 1 | close(DESCRIPTOR); | |||||||||||
| 201 | } | ||||||||||||
| 202 | } | ||||||||||||
| 203 | } | ||||||||||||
| 204 | } | ||||||||||||
| 205 | |||||||||||||
| 206 | sub try_freebsd | ||||||||||||
| 207 | 4 | ▶ | { | ||||||||||
|
Subroutine
try_freebsd: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||
| 208 | 4 | my $self = shift; | |||||||||||
| 209 | 4 | my $current_dir = $self->directory; | |||||||||||
| 210 | |||||||||||||
| 211 | 4 | ▶ | $current_dir.='/' unless ($current_dir =~ /\/$/); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 212 | |||||||||||||
| 213 | 4 | my $current_file=$current_dir.'../'.'INDEX'; | |||||||||||
| 214 | |||||||||||||
| 215 | 4 | ▶ | if ( -f $current_file ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 216 | 1 | ▶ | if ( -r _ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 217 | 1 | ▶ | if (open(DESCRIPTOR,"<".$current_file)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 218 | # ok, we got the dirs | ||||||||||||
| 219 | 1 | my $got_the_file = 0; | |||||||||||
| 220 | 1 | my @desc; | |||||||||||
| 221 | 1 | ▶ | while (<DESCRIPTOR>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 222 | 2 | chomp; | |||||||||||
| 223 | # chomping a probable \r also... | ||||||||||||
| 224 | 2 | chomp; | |||||||||||
| 225 | # start picking up the passangers | ||||||||||||
| 226 | 2 | @desc = split (/\|/,$_); | |||||||||||
| 227 | 2 | ▶ | if ($#desc = 6) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 228 | 2 | my $current_test = $current_dir.$desc[0].'.tgz'; | |||||||||||
| 229 | 2 | ▶ | if ( -e $current_test ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 230 | 1 | $self->{desc}->{ $self->{dir} }->{$desc[0].'.tgz'} = $desc[3]; | |||||||||||
| 231 | } | ||||||||||||
| 232 | } | ||||||||||||
| 233 | } | ||||||||||||
| 234 | 1 | close(DESCRIPTOR); | |||||||||||
| 235 | } | ||||||||||||
| 236 | } | ||||||||||||
| 237 | } | ||||||||||||
| 238 | } | ||||||||||||
| 239 | |||||||||||||
| 240 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||
| 241 | |||||||||||||
| 242 | 1 | 1; | |||||||||||
| 243 | __END__ | ||||||||||||