lib/TUI/StdDlg/FileDialog.pm

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