lib/TUI/StdDlg/FileDialog.pm

filter: Statementstmt 32.2% 102 / 316 Branchbran 0.0% 0 / 100 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 60.4% 26 / 43 Podpod 90.9% 10 / 11 totaltotal 26.2% 138 / 526 CC 64 SCAR 42.1
CC
64
Cov
23%
getFileName
182.0
valid
182.0
BUILD
110.0
CRAP 67.3
« lib/TUI/Views/View.pm ↑ Summary lib/TUI/Menus/MenuBox.pm »
1 package TUI::StdDlg::FileDialog;
2 # ABSTRACT: Common file dialogs
3
4 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 4 our $VERSION = '2.000002';
9 4 $VERSION =~ tr/_//d;
10 4 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 4 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 our @EXPORT = qw(
14 TFileDialog
15 new_TFileDialog
16 );
17
18 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Scalar::Util qw( readonly );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 Maybe
23 :is
24 :types
25 4 );
26
27 4 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
28 bfDefault
29 bfNormal
30 4 );
31 4 ▶use TUI::Dialogs::Button;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 4 ▶use TUI::Dialogs::Dialog;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 4 ▶use TUI::Dialogs::Label;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 4 ▶use TUI::Dialogs::History;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 4 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
36 evBroadcast
37 evCommand
38 4 );
39 4 ▶use TUI::MsgBox::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
40 mfError
41 mfOKButton
42 4 );
43 4 ▶use TUI::MsgBox::MsgBoxText qw( messageBox );
Subroutine BEGIN: called CC=1 SCAR=0.0
44 4 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 4 ▶use TUI::StdDlg::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
46 MAXPATH
47 :cmXXXX
48 :fdXXXX
49 4 );
50 4 ▶use TUI::StdDlg::Dir qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
51 4 ▶use TUI::StdDlg::FileInfoPane;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 4 ▶use TUI::StdDlg::FileInputLine;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 4 ▶use TUI::StdDlg::FileList;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 4 ▶use TUI::StdDlg::Util qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
55 4 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
56 cmCancel
57 cmHelp
58 cmOK
59 cmValid
60 ofCentered
61 4 );
62 4 ▶use TUI::Views::ScrollBar;
Subroutine BEGIN: called CC=1 SCAR=0.0
63
64 sub TFileDialog() { __PACKAGE__ }
65 sub name() { 'TFileDialog' }
66 0 ▶sub new_TFileDialog { __PACKAGE__->from(@_) }
Subroutine new_TFileDialog: not called CC=1 SCAR=6.9
Pod documented
67
68 4 extends TDialog;
69
70 # declare global variables
71 4 our $filesText = "~F~iles";
72 4 our $openText = "~O~pen";
73 4 our $okText = "~O~K";
74 4 our $replaceText = "~R~eplace";
75 4 our $clearText = "~C~lear";
76 4 our $cancelText = "~C~ancel";
77 4 our $helpText = "~H~elp";
78 4 our $invalidDriveText = "Invalid drive or directory";
79 4 our $invalidFileText = "Invalid file name.";
80
81 # public attributes
82 4 has fileName => ( is => 'rw' );
83 4 has fileList => ( is => 'rw' );
84 0 ▶has wildCard => ( is => 'rw', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
85 4 has directory => ( is => 'rw', default => '' );
86
87 # predeclare private methods
88 my (
89 4 $readDirectory,
90 $checkDirectory,
91 );
92
93 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
94 0 state $sig = signature(
95 method => 1,
96 named => [
97 wildCard => Str, { alias => 'aWildCard' },
98 title => Str, { alias => 'aTitle' },
99 inputName => Str,
100 options => PositiveOrZeroInt, { alias => 'aOptions' },
101 histId => PositiveOrZeroInt,
102 ],
103 caller_level => +1,
104 );
105 0 my ( $class, $args1 ) = $sig->( @_ );
106 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
107 my $args2 = $class->SUPER::BUILDARGS(
108 bounds => TRect->new( ax => 15, ay => 1, bx => 64, by => 20 ),
109 title => $args1->{title},
110 0 );
111 0 return { %$args1, %$args2 };
112 }
113
114 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=10 SCAR=47.0
Pod documented
115 0 my ( $self, $args ) = @_;
116 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
117 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
118 0 ▶ assert ( is_HashRef $args );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_HashRef($args) 0 0 0
119 0 $self->{options} |= ofCentered;
120
121 0 $self->{fileName} = TFileInputLine->new(
122 bounds => TRect->new( ax => 3, ay => 3, bx => 31, by => 4 ),
123 maxLen => MAXPATH,
124 );
125
126 0 $self->{fileName}{data} = substr( $self->{wildCard}, 0, MAXPATH );
127 0 $self->insert( $self->{fileName} );
128
129 $self->insert( TLabel->new(
130 bounds => TRect->new(
131 ax => 2, ay => 2,
132 bx => 3 + length( $args->{inputName} ), by => 3,
133 ),
134 text => $args->{inputName},
135 link => $self->{fileName},
136 0 ));
137 $self->insert( THistory->new(
138 bounds => TRect->new( ax => 31, ay => 3, bx => 34, by => 4 ),
139 link => $self->{fileName},
140 historyId => $args->{histId},
141 0 ));
142 0 my $sb = TScrollBar->new(
143 bounds => TRect->new( ax => 3, ay => 14, bx => 34, by => 15 )
144 );
145 0 $self->insert( $sb );
146 0 $self->insert( $self->{fileList} = TFileList->new(
147 bounds => TRect->new( ax => 3, ay => 6, bx => 34, by => 14 ),
148 vScrollBar => $sb,
149 ));
150 $self->insert( TLabel->new(
151 bounds => TRect->new( ax => 2, ay => 5, bx => 8, by => 6 ),
152 text => $args->{inputName},
153 link => $self->{fileName},
154 0 ));
155
156 0 my $opt = bfDefault;
157 0 my $r = TRect->new( ax => 35, ay => 3, bx => 46, by => 5 );
158 0 ▶ if ( $args->{options} & fdOpenButton ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"options"} & 2) 0 0 0
159 0 $self->insert( TButton->new(
160 bounds => $r,
161 title => $openText,
162 command => cmFileOpen,
163 flags => $opt,
164 ));
165 0 $opt = bfNormal;
166 0 $r->{a}{y} += 3;
167 0 $r->{b}{y} += 3;
168 }
169
170 0 ▶ if ( $args->{options} & fdOKButton ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"options"} & 1) 0 0 0
171 0 $self->insert( TButton->new(
172 bounds => $r,
173 title => $okText,
174 command => cmFileOpen,
175 flags => $opt,
176 ));
177 0 $opt = bfNormal;
178 0 $r->{a}{y} += 3;
179 0 $r->{b}{y} += 3;
180 }
181
182 0 ▶ if ( $args->{options} & fdReplaceButton ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"options"} & 4) 0 0 0
183 0 $self->insert( TButton->new(
184 bounds => $r,
185 title => $replaceText,
186 command => cmFileReplace,
187 flags => $opt,
188 ));
189 0 $opt = bfNormal;
190 0 $r->{a}{y} += 3;
191 0 $r->{b}{y} += 3;
192 }
193
194 0 ▶ if ( $args->{options} & fdClearButton ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"options"} & 8) 0 0 0
195 0 $self->insert( TButton->new(
196 bounds => $r,
197 title => $clearText,
198 command => cmFileClear,
199 flags => $opt,
200 ));
201 0 $opt = bfNormal;
202 0 $r->{a}{y} += 3;
203 0 $r->{b}{y} += 3;
204 }
205
206 0 $self->insert( TButton->new(
207 bounds => $r,
208 title => $cancelText,
209 command => cmCancel,
210 flags => bfNormal,
211 ));
212 0 $r->{a}{y} += 3;
213 0 $r->{b}{y} += 3;
214
215 0 ▶ if ( $args->{options} & fdHelpButton ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"options"} & 16) 0 0 0
216 0 $self->insert( TButton->new(
217 bounds => $r,
218 title => $helpText,
219 command => cmHelp,
220 flags => bfNormal,
221 ));
222 0 $opt = bfNormal;
223 0 $r->{a}{y} += 3;
224 0 $r->{b}{y} += 3;
225 }
226
227 0 $self->insert( TFileInfoPane->new(
228 bounds => TRect->new( ax => 1, ay => 16, bx => 48, by => 18 )
229 ));
230
231 0 $self->selectNext( false );
232 $self->$readDirectory()
233 0 ▶ unless $args->{options} & fdNoLoadDir;
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"options"} & 256 0 0 0
234
235 0 return;
236 }
237
238 0 ▶sub from { # $obj ($aWildCard, $aTitle, $inputName, $aOptions, $histId)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
239 0 state $sig = signature(
240 method => 1,
241 pos => [Str, Str, Str, PositiveOrZeroInt, PositiveOrZeroInt],
242 );
243 0 my ( $class, @args ) = $sig->( @_ );
244 0 return $class->new( wildCard => $args[0], title => $args[1],
245 inputName => $args[2], options => $args[3], histId => $args[4] );
246 }
247
248 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod documented
249 0 my ( $self, $in_global_destruction ) = @_;
250 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
251 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
252 0 $self->{directory} = undef;
253 0 return;
254 }
255
256 0 ▶sub getData { # void (\@rec)
Subroutine getData: not called CC=1 SCAR=6.9
Pod documented
257 0 state $sig = signature(
258 method => Object,
259 pos => [ArrayLike],
260 );
261 0 my ( $self, $rec ) = $sig->( @_ );
262 0 $self->getFileName( $rec->[0] = '' );
263 0 return;
264 }
265
266 0 ▶my $relativePath = sub { # $bool ($path)
Subroutine __ANON__: not called CC=5 SCAR=34.0
267 0 my ( $path ) = @_;
268 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
269 0 ▶ assert ( is_Str $path );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($path) 0 0 0
270 0 ▶ return ( length( $path )
Condition0%0/6
length $path && (substr($path, 0, 1) eq '\\' || substr($path, 1, 1) eq ':')
!ll&&!rl&&r
000
substr($path, 0, 1) eq "\\" or substr($path, 1, 1) eq ":"
l!l&&r!l&&!r
000
MC/DC0%0/3
length $path && (substr($path, 0, 1) eq '\\' || substr($path, 1, 1) eq ':')
length $path substr($path, 0, 1) eq "\\" substr($path, 1, 1) eq ":"
Truth table0%0/4
A && B or C
A= length $pathB= substr($path, 0, 1) eq "\\"C= substr($path, 1, 1) eq ":"
ABCresult
0XX0
1000
11X1
1011
271 && ( substr( $path, 0, 1 ) eq '\\' || substr( $path, 1, 1 ) eq ':' ) );
272 4 };
273
274 0 ▶my $noWildChars = sub { # void ($dest, $src)
Subroutine __ANON__: not called CC=5 SCAR=34.0
275 0 my ( $dest, $src ) = @_;
276 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
277 0 ▶ assert ( is_Str $dest );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($dest) 0 0 0
278 0 ▶ assert ( is_Str $src );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($src) 0 0 0
279 0 ▶ assert ( not readonly $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($_[0]) 0 0 0
280 0 $src =~ s/[?*]//g;
281 0 $_[0] = $src;
282 0 return;
283 4 };
284
285 0 ▶my $trim = sub { # void ($dest, $src)
Subroutine __ANON__: not called CC=6 SCAR=37.4
286 0 my ( $dest, $src ) = @_;
287 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
288 0 ▶ assert ( is_Str $dest );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($dest) 0 0 0
289 0 ▶ assert ( is_Str $src );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($src) 0 0 0
290 0 ▶ assert ( not readonly $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($_[0]) 0 0 0
291 0 $src =~ s/^\s+//;
292 0 ▶ if ( $src =~ /^(\S+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ /^(\S+)/) { } 0 0 0
293 0 $dest = $1;
294 }
295 else {
296 0 $dest = '';
297 }
298 0 $_[0] = $dest;
299 0 return;
300 4 };
301
302 0 ▶sub getFileName { # void ($s)
Subroutine getFileName: not called CC=13 SCAR=52.0
Pod documented
303 0 state $sig = signature(
304 method => Object,
305 pos => [Maybe[Str]],
306 );
307 0 my ( $self, $s ) = $sig->( @_ );
308 0 ▶ assert ( not readonly $_[1] );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($_[1]) 0 0 0
309
310 0 my $buf = '';
311 0 my $drive = '';
312 0 my $path = '';
313 0 my $name = '';
314 0 my $ext = '';
315 0 my $TName = '';
316 0 my $TExt = '';
317
318 0 &$trim( $buf, $self->{fileName}{data} );
319 0 ▶ if ( &$relativePath( $buf ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$relativePath($buf)) 0 0 0
320 0 $buf = $self->{directory};
321 0 &$trim( local $_ = '', $self->{fileName}{data} );
322 0 substr( $buf, length( $buf ) ) = $_;
323 }
324
325 # Resolve relative names against the currently selected directory.
326 0 fexpand( $buf, $self->{directory} );
327 0 fnsplit( $buf, $drive, $path, $name, $ext );
328
329 0 ▶ if ( ( $name eq '' || $ext eq '' ) && !isDir( $buf ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "" || $ext eq "" and not isDir($buf)) 0 0 0
Condition0%0/6
$name eq "" || $ext eq "" and not isDir($buf)
!ll&&!rl&&r
000
$name eq "" or $ext eq ""
l!l&&r!l&&!r
000
MC/DC0%0/3
$name eq "" || $ext eq "" and not isDir($buf)
$name eq "" $ext eq "" not isDir($buf)
Truth table0%0/5
A or B and not(C)
A= $name eq ""B= $ext eq ""C= not isDir($buf)
ABCresult
00X0
1X00
0100
1X11
0111
330 0 fnsplit( $self->{wildCard}, undef, undef, $TName, $TExt );
331 0 ▶ if ( $name eq '' && $ext eq '' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq '' and $ext eq '') { } 0 0 0
elsif ($name eq '') { } 0 0 0
elsif ($ext eq '') { } 0 0 0
Condition0%0/3
$name eq "" and $ext eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "" and $ext eq ""
$name eq "" $ext eq ""
Truth table0%0/3
A and B
A= $name eq ""B= $ext eq ""
ABresult
0X0
100
111
332 0 fnmerge( $buf, $drive, $path, $TName, $TExt );
333 }
334 elsif ( $name eq '' ) {
335 0 fnmerge( $buf, $drive, $path, $TName, $ext );
336 }
337 elsif ( $ext eq '' ) {
338 0 ▶ if ( isWild( $name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (isWild($name)) { } 0 0 0
339 0 fnmerge( $buf, $drive, $path, $name, $TExt );
340 }
341 else {
342 0 fnmerge( $buf, $drive, $path, $name, undef );
343 0 &$noWildChars( local $_ = '', $TExt );
344 0 ▶ substr( $buf, length( $buf ) ) = $_
Branch: 1 branch
BranchTrueFalseTotal
if length $_ and $_ ne "." 0 0 0
Condition0%0/3
length $_ and $_ ne "."
!ll&&!rl&&r
000
MC/DC0%0/2
length $_ and $_ ne "."
length $_ $_ ne "."
Truth table0%0/3
A and B
A= length $_B= $_ ne "."
ABresult
0X0
100
111
345 if length( $_ ) && $_ ne '.';
346 }
347 }
348 } #/ if ( ( $name eq '' || ...))
349
350 0 $_[1] = $buf;
351 0 return;
352 }
353
354 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=8 SCAR=40.3
Pod documented
355 4 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
356 0 state $sig = signature(
357 method => Object,
358 pos => [Object],
359 );
360 0 my ( $self, $event ) = $sig->( @_ );
361 0 $self->SUPER::handleEvent( $event );
362 0 ▶ if ( $event->{what} == evCommand ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($event->{'what'} == 256) { } 0 0 0
elsif ($event->{'what'} == 512 and $event->{'message'}{'command'} == 103) { } 0 0 0
363 0 SWITCH: for ( $event->{message}{command} ) {
364 cmFileOpen == $_ ||
365 cmFileReplace == $_ ||
366 0 ▶ cmFileClear == $_ and do {
Branch: 1 branch
BranchTrueFalseTotal
1001 == $_ || 1002 == $_ || 1003 == $_ and do { $self->endModal($event->{"message"}{"command"}); $self->clearEvent($event); last } 0 0 0
Condition0%0/6
1001 == $_ or 1002 == $_ or 1003 == $_
l!l&&r!l&&!r
000
1001 == $_ or 1002 == $_
l!l&&r!l&&!r
000
MC/DC0%0/3
1001 == $_ or 1002 == $_ or 1003 == $_
1001 == $_ 1002 == $_ 1003 == $_
Truth table0%0/4
A or B or C
A= 1001 == $_B= 1002 == $_C= 1003 == $_
ABCresult
1XX1
01X1
0011
0000
367 0 $self->endModal( $event->{message}{command} );
368 0 $self->clearEvent( $event );
369 0 last;
370 };
371 DEFAULT: {
372 0 last;
373 }
374 }
375 }
376 ▶ elsif ( $event->{what} == evBroadcast
Condition0%0/3
$event->{"what"} == 512 and $event->{"message"}{"command"} == 103
!ll&&!rl&&r
000
MC/DC0%0/2
$event->{"what"} == 512 and $event->{"message"}{"command"} == 103
$event->{"what"} == 512 $event->{"message"}{"command"} == 103
Truth table0%0/3
A and B
A= $event->{"what"} == 512B= $event->{"message"}{"command"} == 103
ABresult
0X0
100
111
377 && $event->{message}{command} == cmFileDoubleClicked
378 ) {
379 0 $event->{what} = evCommand;
380 0 $event->{message}{command} = cmOK;
381 0 $self->putEvent( $event );
382 0 $self->clearEvent( $event );
383 }
384
385 0 return;
386 } #/ sub handleEvent
387
388 0 ▶sub setData { # void (\@rec)
Subroutine setData: not called CC=3 SCAR=24.8
Pod documented
389 0 state $sig = signature(
390 method => Object,
391 pos => [ArrayLike],
392 );
393 0 my ( $self, $rec ) = $sig->( @_ );
394 0 $self->SUPER::setData( $rec );
395 0 ▶ if ( length $rec->[0] && isWild( $rec->[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $rec->[0] and isWild($rec->[0])) 0 0 0
Condition0%0/3
length $rec->[0] and isWild($rec->[0])
!ll&&!rl&&r
000
MC/DC0%0/2
length $rec->[0] and isWild($rec->[0])
length $rec->[0] isWild($rec->[0])
Truth table0%0/3
A and B
A= length $rec->[0]B= isWild($rec->[0])
ABresult
0X0
100
111
396 0 $self->valid( cmFileInit );
397 0 $self->{fileName}->select();
398 }
399 0 return;
400 }
401
402 0 ▶sub valid { # $bool ($command)
Subroutine valid: not called CC=13 SCAR=52.0
Pod documented
403 0 state $sig = signature(
404 method => Object,
405 pos => [PositiveOrZeroInt],
406 );
407 0 my ( $self, $command ) = $sig->( @_ );
408
409 0 my ( $fName, $drive, $dir, $name, $ext ) = ( '', '', '', '', '' );
410
411 0 ▶ return false
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::valid($command) 0 0 0
412 unless $self->SUPER::valid( $command );
413
414 # The base TDialog::valid() doesn't handle these.
415 0 ▶ return true
Branch: 1 branch
BranchTrueFalseTotal
if $command == 0 or $command == 11 or $command == 1003 0 0 0
Condition0%0/6
$command == 0 or $command == 11 or $command == 1003
l!l&&r!l&&!r
000
$command == 0 or $command == 11
l!l&&r!l&&!r
000
MC/DC0%0/3
$command == 0 or $command == 11 or $command == 1003
$command == 0 $command == 11 $command == 1003
Truth table0%0/4
A or B or C
A= $command == 0B= $command == 11C= $command == 1003
ABCresult
1XX1
01X1
0011
0000
416 if $command == cmValid || $command == cmCancel || $command == cmFileClear;
417
418 0 $self->getFileName( $fName );
419
420 0 ▶ if ( isWild( $fName ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (isWild($fName)) 0 0 0
421 0 fnsplit( $fName, $drive, $dir, $name, $ext );
422 0 my $path = $drive . $dir;
423
424 0 ▶ if ( $self->$checkDirectory( $path ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->$checkDirectory($path)) 0 0 0
425 0 $self->{directory} = $path;
426 0 $self->{wildCard} = $name . $ext;
427 0 ▶ if ( $command != cmFileInit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command != 1004) 0 0 0
428 0 $self->{fileList}->select();
429 }
430 0 $self->{fileList}->readDirectory( $self->{directory}, $self->{wildCard} );
431 }
432
433 0 return false;
434 } #/ if ( isWild( $fName ) )
435
436 0 ▶ if ( isDir( $fName ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDir($fName)) 0 0 0
437 0 ▶ if ( $self->$checkDirectory( $fName ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->$checkDirectory($fName)) 0 0 0
438
439 # BUG FIX - EFW - Fixed incorrect addition of an
440 # additional backslash under certain circumstances.
441 0 ▶ $fName .= '\\'
Branch: 1 branch
BranchTrueFalseTotal
unless $fName =~ /\\$/ 0 0 0
442 if $fName !~ /\\$/;
443
444 0 $self->{directory} = $fName;
445 0 ▶ if ( $command != cmFileInit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command != 1004) 0 0 0
446 0 $self->{fileList}->select();
447 }
448 0 $self->{fileList}->readDirectory( $self->{directory}, $self->{wildCard} );
449 }
450
451 0 return false;
452 } #/ if ( isDir( $fName ) )
453
454 0 ▶ if ( validFileName( $fName ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (validFileName($fName)) 0 0 0
455 0 return true
456 }
457
458 0 messageBox( $invalidDriveText, mfError | mfOKButton );
459 0 return false;
460 }
461
462 0 ▶sub shutDown { # void ($self)
Subroutine shutDown: not called CC=1 SCAR=6.9
Pod documented
463 0 state $sig = signature(
464 method => Object,
465 pos => [],
466 );
467 0 my ( $self ) = $sig->( @_ );
468 0 $self->{fileName} = undef;
469 0 $self->{fileList} = undef;
470 0 $self->SUPER::shutDown();
471 0 return;
472 }
473
474 0 ▶$readDirectory = sub { # void ()
Subroutine __ANON__: not called CC=3 SCAR=24.8
475 0 my ( $self ) = @_;
476 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
477 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
478 0 my $curDir = '';
479 0 getCurDir( $curDir );
480 0 $self->{directory} = $curDir;
481 0 $self->{fileList}->readDirectory( $self->{wildCard} );
482 0 return;
483 4 };
484
485 0 ▶$checkDirectory = sub { # $bool ($str)
Subroutine __ANON__: not called CC=5 SCAR=34.0
486 0 my ( $self, $str ) = @_;
487 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
488 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
489 0 ▶ assert ( is_Str $str );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($str) 0 0 0
490 0 ▶ if ( pathValid( $str ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (pathValid($str)) { } 0 0 0
491 0 return true
492 }
493 else {
494 0 messageBox( $invalidDriveText, mfError | mfOKButton );
495 0 $self->{fileName}->select();
496 0 return false;
497 }
498 4 };
499
500 4 1
501
502 __END__
« lib/TUI/Views/View.pm ↑ Summary lib/TUI/Menus/MenuBox.pm »