slightly edited version of suggested patch
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / OS2.pm
1 package File::Spec::OS2;
2
3 use strict;
4 use vars qw(@ISA);
5 require File::Spec::Unix;
6 @ISA = qw(File::Spec::Unix);
7
8 sub devnull {
9     return "/dev/nul";
10 }
11
12 sub file_name_is_absolute {
13     my ($self,$file) = @_;
14     return scalar($file =~ m{^([a-z]:)?[\\/]}i);
15 }
16
17 sub path {
18     my $path = $ENV{PATH};
19     $path =~ s:\\:/:g;
20     my @path = split(';',$path);
21     foreach (@path) { $_ = '.' if $_ eq '' }
22     return @path;
23 }
24
25 my $tmpdir;
26 sub tmpdir {
27     return $tmpdir if defined $tmpdir;
28     my $self = shift;
29     foreach (@ENV{qw(TMPDIR TEMP TMP)}, qw(/tmp /)) {
30         next unless defined && -d;
31         $tmpdir = $_;
32         last;
33     }
34     $tmpdir = '' unless defined $tmpdir;
35     $tmpdir =~ s:\\:/:g;
36     $tmpdir = $self->canonpath($tmpdir);
37     return $tmpdir;
38 }
39
40 1;
41 __END__
42
43 =head1 NAME
44
45 File::Spec::OS2 - methods for OS/2 file specs
46
47 =head1 SYNOPSIS
48
49  require File::Spec::OS2; # Done internally by File::Spec if needed
50
51 =head1 DESCRIPTION
52
53 See File::Spec::Unix for a documentation of the methods provided
54 there. This package overrides the implementation of these methods, not
55 the semantics.