Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add symlink and link
  • Loading branch information
FROGGS committed Apr 12, 2013
1 parent 3e1b44f commit 4e37f55
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -296,6 +296,22 @@ my class X::IO::Copy does X::IO is Exception {
}
}

my class X::IO::Symlink does X::IO is Exception {
has $.target;
has $.name;
method message() {
"Failed to create symlink called '$.name' on target '$.target': $.os-error"
}
}

my class X::IO::Link does X::IO is Exception {
has $.target;
has $.name;
method message() {
"Failed to create link called '$.name' on target '$.target': $.os-error"
}
}

my class X::IO::Mkdir does X::IO is Exception {
has $.path;
has $.mode;
Expand Down
28 changes: 28 additions & 0 deletions src/core/IO.pm
Expand Up @@ -507,5 +507,33 @@ 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;
CATCH {
default {
X::IO::Symlink.new(
:$target,
:$name,
os-error => .Str,
).throw;
}
}
}
sub link(Cool $target as Str, Cool $name as Str) {
nqp::link(nqp::unbox_s($target), nqp::unbox_s($name));
return True;
CATCH {
default {
X::IO::Link.new(
:$target,
:$name,
os-error => .Str,
).throw;
}
}
}

sub chmod($mode, $filename) { $filename.IO.chmod($mode); $filename }
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2013.03-14-g8a6373f
2013.03-15-g5104c2e

0 comments on commit 4e37f55

Please sign in to comment.