Commit | Line | Data |
ecf68df6 |
1 | package File::Spec::Cygwin; |
2 | |
3 | use strict; |
4 | use vars qw(@ISA $VERSION); |
5 | require File::Spec::Unix; |
6 | |
6f0dcf97 |
7 | $VERSION = '1.1'; |
ecf68df6 |
8 | |
9 | @ISA = qw(File::Spec::Unix); |
10 | |
07824bd1 |
11 | =head1 NAME |
12 | |
13 | File::Spec::Cygwin - methods for Cygwin file specs |
14 | |
15 | =head1 SYNOPSIS |
16 | |
17 | require File::Spec::Cygwin; # Done internally by File::Spec if needed |
18 | |
19 | =head1 DESCRIPTION |
20 | |
72f15715 |
21 | See L<File::Spec> and L<File::Spec::Unix>. This package overrides the |
22 | implementation of these methods, not the semantics. |
07824bd1 |
23 | |
24 | This module is still in beta. Cygwin-knowledgeable folks are invited |
25 | to offer patches and suggestions. |
26 | |
27 | =cut |
28 | |
29 | =pod |
30 | |
95fb0f99 |
31 | =over 4 |
32 | |
07824bd1 |
33 | =item canonpath |
34 | |
35 | Any C<\> (backslashes) are converted to C</> (forward slashes), |
36 | and then File::Spec::Unix canonpath() is called on the result. |
37 | |
38 | =cut |
39 | |
ecf68df6 |
40 | sub canonpath { |
41 | my($self,$path) = @_; |
42 | $path =~ s|\\|/|g; |
43 | return $self->SUPER::canonpath($path); |
44 | } |
45 | |
07824bd1 |
46 | =pod |
47 | |
48 | =item file_name_is_absolute |
49 | |
50 | True is returned if the file name begins with C<drive_letter:>, |
51 | and if not, File::Spec::Unix file_name_is_absolute() is called. |
52 | |
53 | =cut |
54 | |
55 | |
3ed25742 |
56 | sub file_name_is_absolute { |
57 | my ($self,$file) = @_; |
58 | return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test |
59 | return $self->SUPER::file_name_is_absolute($file); |
60 | } |
61 | |
07824bd1 |
62 | =item tmpdir (override) |
f534ab20 |
63 | |
07824bd1 |
64 | Returns a string representation of the first existing directory |
65 | from the following list: |
ecf68df6 |
66 | |
07824bd1 |
67 | $ENV{TMPDIR} |
68 | /tmp |
69 | C:/temp |
ecf68df6 |
70 | |
07824bd1 |
71 | Since Perl 5.8.0, if running under taint mode, and if the environment |
72 | variables are tainted, they are not used. |
ecf68df6 |
73 | |
07824bd1 |
74 | =cut |
ecf68df6 |
75 | |
07824bd1 |
76 | my $tmpdir; |
77 | sub tmpdir { |
78 | return $tmpdir if defined $tmpdir; |
79 | my $self = shift; |
80 | $tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' ); |
81 | } |
ecf68df6 |
82 | |
95fb0f99 |
83 | =back |
84 | |
85 | =cut |
86 | |
07824bd1 |
87 | 1; |