Upgrade to File::Spec 0.85.
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Epoc.pm
1 package File::Spec::Epoc;
2
3 use strict;
4 use Cwd;
5 use vars qw($VERSION @ISA);
6
7 $VERSION = '1.1';
8
9 require File::Spec::Unix;
10 @ISA = qw(File::Spec::Unix);
11
12 =head1 NAME
13
14 File::Spec::Epoc - methods for Epoc file specs
15
16 =head1 SYNOPSIS
17
18  require File::Spec::Epoc; # Done internally by File::Spec if needed
19
20 =head1 DESCRIPTION
21
22 See File::Spec::Unix for a documentation of the methods provided
23 there. This package overrides the implementation of these methods, not
24 the semantics.
25
26 This package is still work in progress ;-)
27
28 =head1 AUTHORS
29
30 o.flebbe@gmx.de
31
32 =cut
33
34 sub case_tolerant {
35     return 1;
36 }
37
38 =pod
39
40 =over 4
41
42 =item canonpath()
43
44 No physical check on the filesystem, but a logical cleanup of a
45 path. On UNIX eliminated successive slashes and successive "/.".
46
47 =back
48
49 =cut
50
51 sub canonpath {
52     my ($self,$path) = @_;
53
54     $path =~ s|/+|/|g;                             # xx////xx  -> xx/xx
55     $path =~ s|(/\.)+/|/|g;                        # xx/././xx -> xx/xx
56     $path =~ s|^(\./)+||s unless $path eq "./";    # ./xx      -> xx
57     $path =~ s|^/(\.\./)+|/|s;                     # /../../xx -> xx
58     $path =~  s|/\Z(?!\n)|| unless $path eq "/";          # xx/       -> xx
59     return $path;
60 }
61
62 =head1 SEE ALSO
63
64 L<File::Spec>
65
66 =cut
67
68 1;