Skip to content

Commit cb5db6b

Browse files
authored
Merge pull request #59 from fglock/fix-commonsense-test
Fix t/lib/commonsense.t by adding File::Glob module
2 parents 01c8600 + 40169d6 commit cb5db6b

File tree

2 files changed

+122
-2
lines changed

2 files changed

+122
-2
lines changed

src/main/perl/lib/Config.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ $os_name =~ s/\s+/_/g;
195195
useperlio => 'define',
196196

197197
# Extensions available in PerlOnJava
198-
extensions => 'Socket IO::Socket',
199-
dynamic_ext => 'Socket IO::Socket',
198+
extensions => 'Fcntl IO File/Glob Socket IO::Socket',
199+
dynamic_ext => 'Fcntl IO File/Glob Socket IO::Socket',
200200
static_ext => '',
201201

202202
# File operations

src/main/perl/lib/File/Glob.pm

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package File::Glob;
2+
3+
use strict;
4+
use warnings;
5+
6+
our $VERSION = '1.39';
7+
8+
use Exporter 'import';
9+
10+
our @EXPORT_OK = qw(
11+
glob
12+
bsd_glob
13+
GLOB_ERROR
14+
GLOB_CSH
15+
GLOB_NOMAGIC
16+
GLOB_QUOTE
17+
GLOB_TILDE
18+
GLOB_BRACE
19+
GLOB_NOCHECK
20+
GLOB_NOSORT
21+
GLOB_NOSPACE
22+
GLOB_ABEND
23+
GLOB_ALPHASORT
24+
GLOB_ALTDIRFUNC
25+
);
26+
27+
our %EXPORT_TAGS = (
28+
'glob' => [ qw(
29+
glob
30+
bsd_glob
31+
GLOB_ERROR
32+
GLOB_CSH
33+
GLOB_NOMAGIC
34+
GLOB_QUOTE
35+
GLOB_TILDE
36+
GLOB_BRACE
37+
GLOB_NOCHECK
38+
GLOB_NOSORT
39+
GLOB_NOSPACE
40+
GLOB_ABEND
41+
GLOB_ALPHASORT
42+
GLOB_ALTDIRFUNC
43+
) ],
44+
);
45+
46+
# Constants for glob flags
47+
use constant {
48+
GLOB_ERROR => 0,
49+
GLOB_CSH => 1,
50+
GLOB_NOMAGIC => 2,
51+
GLOB_QUOTE => 4,
52+
GLOB_TILDE => 8,
53+
GLOB_BRACE => 16,
54+
GLOB_NOCHECK => 32,
55+
GLOB_NOSORT => 64,
56+
GLOB_NOSPACE => 128,
57+
GLOB_ABEND => 256,
58+
GLOB_ALPHASORT => 512,
59+
GLOB_ALTDIRFUNC => 1024,
60+
};
61+
62+
# bsd_glob implementation - use Perl's built-in glob for now
63+
sub bsd_glob {
64+
my $pattern = shift;
65+
my $flags = shift || 0;
66+
67+
# For now, just use Perl's built-in glob
68+
# In the future, we could implement the flags properly
69+
return CORE::glob($pattern);
70+
}
71+
72+
# Regular glob - just use built-in
73+
sub glob {
74+
my $pattern = shift;
75+
return CORE::glob($pattern);
76+
}
77+
78+
1;
79+
80+
__END__
81+
82+
=head1 NAME
83+
84+
File::Glob - Perl extension for BSD glob routine
85+
86+
=head1 SYNOPSIS
87+
88+
use File::Glob ':glob';
89+
90+
@list = bsd_glob('*.txt');
91+
92+
=head1 DESCRIPTION
93+
94+
This is a minimal implementation of File::Glob for PerlOnJava.
95+
It provides basic glob functionality using Perl's built-in glob operator.
96+
97+
=head1 FUNCTIONS
98+
99+
=over 4
100+
101+
=item bsd_glob($pattern [, $flags])
102+
103+
Implements BSD-style globbing. Currently uses Perl's built-in glob.
104+
105+
=item glob($pattern)
106+
107+
Simple wrapper around Perl's built-in glob.
108+
109+
=back
110+
111+
=head1 CONSTANTS
112+
113+
Various GLOB_* constants are exported for compatibility.
114+
115+
=head1 AUTHOR
116+
117+
PerlOnJava Project
118+
119+
=cut
120+

0 commit comments

Comments
 (0)