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 | |
9d5071ba |
46 | sub catdir { |
47 | my $self = shift; |
48 | |
49 | # Don't create something that looks like a //network/path |
50 | if ($_[0] eq '/' or $_[0] eq '\\') { |
51 | shift; |
52 | return $self->SUPER::catdir('', @_); |
53 | } |
54 | |
55 | $self->SUPER::catdir(@_); |
56 | } |
57 | |
07824bd1 |
58 | =pod |
59 | |
60 | =item file_name_is_absolute |
61 | |
62 | True is returned if the file name begins with C<drive_letter:>, |
63 | and if not, File::Spec::Unix file_name_is_absolute() is called. |
64 | |
65 | =cut |
66 | |
67 | |
3ed25742 |
68 | sub file_name_is_absolute { |
69 | my ($self,$file) = @_; |
70 | return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test |
71 | return $self->SUPER::file_name_is_absolute($file); |
72 | } |
73 | |
07824bd1 |
74 | =item tmpdir (override) |
f534ab20 |
75 | |
07824bd1 |
76 | Returns a string representation of the first existing directory |
77 | from the following list: |
ecf68df6 |
78 | |
07824bd1 |
79 | $ENV{TMPDIR} |
80 | /tmp |
81 | C:/temp |
ecf68df6 |
82 | |
07824bd1 |
83 | Since Perl 5.8.0, if running under taint mode, and if the environment |
84 | variables are tainted, they are not used. |
ecf68df6 |
85 | |
07824bd1 |
86 | =cut |
ecf68df6 |
87 | |
07824bd1 |
88 | my $tmpdir; |
89 | sub tmpdir { |
90 | return $tmpdir if defined $tmpdir; |
60598624 |
91 | $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' ); |
07824bd1 |
92 | } |
ecf68df6 |
93 | |
95fb0f99 |
94 | =back |
95 | |
99f36a73 |
96 | =head1 COPYRIGHT |
97 | |
98 | Copyright (c) 2004 by the Perl 5 Porters. All rights reserved. |
99 | |
100 | This program is free software; you can redistribute it and/or modify |
101 | it under the same terms as Perl itself. |
102 | |
95fb0f99 |
103 | =cut |
104 | |
07824bd1 |
105 | 1; |