Perlito5X/Java/File/Glob.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 78 CC 7 SCAR 25.2
CC
7
Cov
0%
import
30.0
bsd_glob
6.0
glob
6.0
CRAP 12.4
1 package File::Glob;
2  
3 use strict;
4 our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, $DEFAULT_FLAGS);
5  
6 @ISA = qw(Exporter);
7  
8 # NOTE: The glob() export is only here for compatibility with 5.6.0.
9 # csh_glob() should not be used directly, unless you know what you're doing.
10  
11 %EXPORT_TAGS = (
12 'glob' => [ qw(
13 GLOB_ABEND
14 GLOB_ALPHASORT
15 GLOB_ALTDIRFUNC
16 GLOB_BRACE
17 GLOB_CSH
18 GLOB_ERR
19 GLOB_ERROR
20 GLOB_LIMIT
21 GLOB_MARK
22 GLOB_NOCASE
23 GLOB_NOCHECK
24 GLOB_NOMAGIC
25 GLOB_NOSORT
26 GLOB_NOSPACE
27 GLOB_QUOTE
28 GLOB_TILDE
29 bsd_glob
30 glob
31 ) ],
32 );
33 $EXPORT_TAGS{bsd_glob} = [@{$EXPORT_TAGS{glob}}];
34 pop @{$EXPORT_TAGS{bsd_glob}}; # no "glob"
35  
36 @EXPORT_OK = (@{$EXPORT_TAGS{'glob'}}, 'csh_glob');
37  
38 $VERSION = '1.28';
39  
40 sub import {
41 require Exporter;
42 local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
43 Exporter::import(grep {
44 my $passthrough;
45 if ($_ eq ':case') {
46 $DEFAULT_FLAGS &= ~GLOB_NOCASE()
47 }
48 elsif ($_ eq ':nocase') {
49 $DEFAULT_FLAGS |= GLOB_NOCASE();
50 }
51 elsif ($_ eq ':globally') {
52 no warnings 'redefine';
53 *CORE::GLOBAL::glob = \&File::Glob::csh_glob;
54 }
55 elsif ($_ eq ':bsd_glob') {
56 no strict; *{caller."::glob"} = \&bsd_glob_override;
57 $passthrough = 1;
58 }
59 else {
60 $passthrough = 1;
61 }
62 $passthrough;
63 } @_);
64 }
65  
66 $DEFAULT_FLAGS = GLOB_CSH();
67 if ($^O =~ /^(?:MSWin32|VMS|os2|dos|riscos)$/) {
68 $DEFAULT_FLAGS |= GLOB_NOCASE();
69 }
70  
71 sub bsd_glob {
72 if (@_) {
73 Java::inline '
74 String pattern = List__.shift().toString();
75 int flags = List__.shift().to_int();
76  
77 PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern);
78  
79 fh.directoryStream = Files.newDirectoryStream(PlV.path);
80 fh.directoryIterator = fh.directoryStream.iterator();
81  
82 // TODO
83 PlCORE.die("Not implemented");
84  
85 ret = new PlArray();
86 return ret
87 ';
88 }
89 return undef;
90 }
91  
92 # File::Glob::glob() is deprecated because its prototype is different from
93 # CORE::glob() (use bsd_glob() instead)
94 sub glob {
95 use 5.024;
96 use warnings ();
97 warnings::warnif (deprecated =>
98 "File::Glob::glob() will disappear in perl 5.30. " .
99 "Use File::Glob::bsd_glob() instead.") unless state $warned ++;
100  
101 splice @_, 1; # no flags
102 goto &bsd_glob;
103 }
104  
105 1;
106 __END__