New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic IO functions #2377
Labels
Comments
From will@worrbase.comrakudo didn't have the ability to rm, copy, move, chmod, or link files This patch was also submitted as a pull request on github. |
From will@worrbase.com0001-Added-move-to-IO.pm.patchFrom 581b99cdc23e474b8b4a8056328ecc013e32b754 Mon Sep 17 00:00:00 2001
From: William Orr <will@worrbase.com>
Date: Thu, 24 Feb 2011 05:05:17 -0500
Subject: [PATCH] Added move to IO.pm
Added chmod
Can look at filesystem permissions
Removed unnecessary functions
- Didn't need all the stuff I wrote
Implemented copy
Added additional basic IO functions
- added rm
- added link
Turns outperl6 does support octal
---
src/core/IO.pm | 42 ++++++++++++++++++++++++++++++++++++++++++
src/core/IO/Stat.pm | 4 ++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/src/core/IO.pm b/src/core/IO.pm
index d60eff5..12d1550 100644
--- a/src/core/IO.pm
+++ b/src/core/IO.pm
@@ -292,4 +292,46 @@ multi sub cwd() {
$! ?? fail($!) !! $pwd;
}
+multi sub move($src as Str, $dest as Str) {
+ try {
+ pir::new__PS('OS').rename($src, $dest);
+ }
+ $! ?? fail($!) !! True
+}
+
+multi sub chmod($path as Str, $mode as Int) {
+ try {
+ pir::new__PS('OS').chmod($path, $mode);
+ }
+ $! ?? fail($!) !! True
+}
+
+multi sub copy($src as Str, $dest as Str) {
+ try {
+ pir::new__PS('File').copy($src, $dest);
+ }
+ $! ?? fail($!) !! True
+}
+
+multi sub rm($path as Str) {
+ try {
+ pir::new__PS('OS').rm($path);
+ }
+ $! ?? fail($!) !! True
+}
+
+multi sub link($src as Str, $dest as Str, Bool :$hard = False) {
+ if $hard {
+ try {
+ pir::new__PS('OS').link($src, $dest);
+ }
+ $! ?? fail($!) !! return True;
+ }
+
+ try {
+ pir::new__PS('OS').symlink($src, $dest);
+ }
+ $! ?? fail($!) !! True
+}
+
# vim: ft=perl6
diff --git a/src/core/IO/Stat.pm b/src/core/IO/Stat.pm
index dba9c86..95ab65d 100644
--- a/src/core/IO/Stat.pm
+++ b/src/core/IO/Stat.pm
@@ -44,6 +44,10 @@ class IO::Stat {
method gid {
pir::stat__isi($.path, 10);
}
+
+ method permissions {
+ pir::stat__isi($.path, -3) +& 0o7777;
+ }
}
# vim: ft=perl6
--
1.7.4.1
|
From @moritzpatch has long been applied, closing ticket, thank you. |
@moritz - Status changed from 'new' to 'resolved' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.perl.org#84950 (status was 'resolved')
Searchable as RT84950$
The text was updated successfully, but these errors were encountered: