Skip to content

Commit

Permalink
add Epoc, tests and all (it was only two functions *shrug*)
Browse files Browse the repository at this point in the history
  • Loading branch information
labster committed Apr 1, 2013
1 parent 8bf56e5 commit e5145ac
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions lib/File/Spec/Epoc.pm
@@ -1,24 +1,29 @@
class File::Spec::Epoc;
use v6;
use File::Spec::Unix;
class File::Spec::Epoc is File::Spec::Unix;

my $module = "File::Spec::Unix";
require $module;

method canonpath { ::($module).canonpath() }
method catdir { ::($module).catdir() }
method catfile { ::($module).catfile() }
method curdir { ::($module).curdir() }
method devnull { ::($module).devnull() }
method rootdir { ::($module).rootdir() }
method tmpdir { ::($module).tmpdir() }
method updir { ::($module).updir() }
method no_upwards { ::($module).no_upwards() }
method case_tolerant { 1 }
method file_name_is_absolute { ::($module).file_name_is_absolute() }
method path { ::($module).path() }
method join { ::($module).join() }
method splitpath { ::($module).splitpath() }
method splitdir { ::($module).splitdir() }
method catpath { ::($module).catpath() }
method abs2rel { ::($module).abs2rel() }
method rel2abs { ::($module).rel2abs() }

method default_case_tolerant { True }
method case_tolerant { True }

method canonpath ($path is copy) {
return unless defined $path;

$path ~~ s:g '/'+ ❙/❙; # xx////xx -> xx/xx
$path ~~ s:g '/.'+ '/' ❙/❙; #: xx/././xx -> xx/xx
$path ~~ s^ './'+❙❙ unless $path eq "./"; # ./xx -> xx
$path ~~ s^ '/' '../'+ ❙/❙; # /../../xx -> xx
$path ~~ s '/' $❙❙ unless $path eq "/"; # xx/ -> xx
return $path;
}


=begin pod
This is a Perl6 port of all Perl 5's File::Spec has for Epoc.
Dead OS is dead. ⛼
See File::Spec::Win32 for Symbian support.
=end pod

0 comments on commit e5145ac

Please sign in to comment.