Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix dir(), panda now runs \o/. Also change splitpath to use :nofile p…

…aram
  • Loading branch information...
commit 02c7fbb8d716e9f1b8eb664d1340fc4b378858eb 1 parent 87edfc0
@labster labster authored
View
22 src/core/IO.pm
@@ -1,6 +1,4 @@
my role IO { }
-# my class X::IO::Copy { ... }
-# my class X::IO::Dir { ... }
sub print(|) {
my $args := pir::perl6_current_args_rpa__P();
@@ -218,7 +216,6 @@ my class IO::Handle does IO::FileTestable {
$! ?? fail(X::IO::Copy.new(from => $.path, to => $dest, os-error => ~$!)) !! True
}
- # my class X::IO::Chmod { ... }
method chmod($mode) {
nqp::chmod(nqp::unbox_s(~$.path), nqp::unbox_i($mode.Int));
return True;
@@ -346,17 +343,18 @@ my class IO::Path::Win32 is IO::Path { method SPEC { IO::Spec::Win32 }; }
my class IO::Path::Cygwin is IO::Path { method SPEC { IO::Spec::Cygwin }; }
-sub dir(Cool $directory = '.', Mu :$test = none('.', '..')) {
- my Mu $RSA := pir::new__PS('OS').readdir(nqp::unbox_s($directory.Str));
- my $path = $directory.path;
+sub dir(Cool $path = '.', Mu :$test = none('.', '..')) {
+ my Mu $RSA := pir::new__PS('OS').readdir(nqp::unbox_s($path.Str));
my int $elems = nqp::elems($RSA);
my @res;
+ my ($directory, $volume) = IO::Spec.splitpath(~$path, :nofile);
loop (my int $i = 0; $i < $elems; $i = $i + 1) {
my Str $file := nqp::p6box_s(pir::trans_encoding__Ssi(
nqp::atpos_s($RSA, $i),
pir::find_encoding__Is('utf8')));
if $file ~~ $test {
- @res.push: $path.child($file);
+ #this should be like IO::Path.child(:basename($file)) because of :volume
+ @res.push: IO::Path.new(:basename($file), :$directory, :$volume);
}
}
return @res.list;
@@ -364,14 +362,13 @@ sub dir(Cool $directory = '.', Mu :$test = none('.', '..')) {
CATCH {
default {
X::IO::Dir.new(
- path => ~$directory,
+ :$path,
os-error => .Str,
).throw;
}
}
}
-# my class X::IO::Unlink { ... }
sub unlink($path) {
nqp::unlink($path);
return True;
@@ -385,7 +382,6 @@ sub unlink($path) {
}
}
-# my class X::IO::Rmdir { ... }
sub rmdir($path) {
nqp::rmdir($path);
return True;
@@ -473,7 +469,6 @@ multi sub spurt(Cool $filename,
$fh.close;
}
-# my class X::IO::Cwd { ... }
proto sub cwd(|) { * }
multi sub cwd() {
return nqp::p6box_s(
@@ -491,7 +486,6 @@ multi sub cwd() {
}
-# my class X::IO::Chdir { ... }
proto sub chdir(|) { * }
multi sub chdir($path as Str) {
nqp::chdir(nqp::unbox_s($path));
@@ -507,7 +501,6 @@ multi sub chdir($path as Str) {
}
}
-# my class X::IO::Mkdir { ... }
proto sub mkdir(|) { * }
multi sub mkdir($path as Str, $mode = 0o777) {
nqp::mkdir($path, $mode);
@@ -529,7 +522,6 @@ $PROCESS::ERR = IO::Handle.new;
nqp::bindattr(nqp::p6decont($PROCESS::ERR),
IO::Handle, '$!PIO', nqp::getstderr());
-# my class X::IO::Rename { ... }
sub rename(Cool $from as Str, Cool $to as Str) {
nqp::rename(nqp::unbox_s($from), nqp::unbox_s($to));
return True;
@@ -560,8 +552,6 @@ sub copy(Cool $from as Str, Cool $to as Str) {
}
}
}
-#my class X::IO::Symlink { ... }
-#my class X::IO::Link { ... }
sub symlink(Cool $target as Str, Cool $name as Str) {
nqp::symlink(nqp::unbox_s($target), nqp::unbox_s($name));
return True;
View
6 src/core/IO/Spec/Unix.pm
@@ -62,7 +62,7 @@ my class IO::Spec::Unix {
return @path
}
- method splitpath( $path, $nofile = False ) {
+ method splitpath( $path, :$nofile = False ) {
my ( $directory, $file ) = ( '', '' );
if $nofile {
@@ -130,8 +130,8 @@ my class IO::Spec::Unix {
$base = self.catdir( self.rootdir, $base );
}
- my ($path_volume, $path_directories) = self.splitpath( $path, 1 );
- my ($base_volume, $base_directories) = self.splitpath( $base, 1 );
+ my ($path_volume, $path_directories) = self.splitpath( $path, :nofile );
+ my ($base_volume, $base_directories) = self.splitpath( $base, :nofile );
# Can't relativize across volumes
return $path unless $path_volume eq $base_volume;
View
6 src/core/IO/Spec/Win32.pm
@@ -81,7 +81,7 @@ my class IO::Spec::Win32 is IO::Spec::Unix {
self.catpath($volume, $directory, $file);
}
- method splitpath($path as Str, $nofile as Bool = False) {
+ method splitpath($path as Str, :$nofile = False) {
my ($volume,$directory,$file) = ('','','');
if ( $nofile ) {
@@ -148,9 +148,9 @@ my class IO::Spec::Win32 is IO::Spec::Unix {
$base = self.canonpath( $base );
}
- my ($path_directories, $path_file) = self.splitpath( $path, False )[1..2] ;
+ my ($path_directories, $path_file) = self.splitpath( $path )[1..2] ;
- my ($base_volume, $base_directories) = self.splitpath( $base, True ) ;
+ my ($base_volume, $base_directories) = self.splitpath( $base, :nofile ) ;
$path = self.catpath(
$base_volume,
Please sign in to comment.
Something went wrong with that request. Please try again.