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 file test methods to IO.pm #2378
Comments
From will@worrbase.comI implemented several of the file test methods listed here: Additionally, I reimplemented IO.l in Perl6 rather than pir, and I Patch also submitted as github pull request. |
From will@worrbase.com0001-Added-nodev-requirement-to-IO.f.patchFrom ef513564a171d724d602216e48f235779753d509 Mon Sep 17 00:00:00 2001
From: William Orr <will@worrbase.com>
Date: Fri, 25 Feb 2011 23:44:27 -0500
Subject: [PATCH] Added nodev requirement to IO.f
- spec says that regular files can be neither devices or directories
Added R(), W(), X()
Added O() and o()
Changed IO.l implementation to Perl6 instead of pir
Implemented u() g() and k()
---
src/core/IO.pm | 60 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/src/core/IO.pm b/src/core/IO.pm
index 12d1550..f1b91ab 100644
--- a/src/core/IO.pm
+++ b/src/core/IO.pm
@@ -147,26 +147,64 @@ class IO is Cool {
$.stat.exists;
}
multi method f() {
- self.e ?? !$.stat.isdir !! Bool;
+ self.e ?? (!$.stat.isdir and !$.stat.isdev) !! Bool;
}
multi method s() {
self.e ?? $.stat.size !! Any;
}
+ multi method R() {
+ ?pir::new__PS('OS').can_read($.path);
+ }
+
+ multi method W() {
+ ?pir::new__PS('OS').can_write($.path);
+ }
+
+ multi method X() {
+ ?pir::new__PS('OS').can_execute($.path);
+ }
+
+ # These are clones of the above functions since parrot can't determine
+ # the effective uid yet
+ multi method r() {
+ ?pir::new__PS('OS').can_read($.path);
+ }
+
+ multi method w() {
+ ?pir::new__PS('OS').can_write($.path);
+ }
+
+ multi method x() {
+ ?pir::new__PS('OS').can_execute($.path);
+ }
+
multi method l() {
- my $fn = $.path;
- ? Q:PIR{
- .local pmc filename, file
- filename = find_lex '$fn'
- $S0 = filename
-
- file = root_new ['parrot';'File']
- $I0 = file.'is_link'($S0)
- %r = box $I0
- }
+ $.stat.islnk;
+ }
+
+ multi method O() {
+ pir::new__PS('OS').get_user_id() ~~ $.stat.uid;
}
+ # Can't get effective uid in parrot
+ multi method o() {
+ pir::new__PS('OS').get_user_id() ~~ $.stat.uid;
+ }
+
+ multi method u() {
+ ?($.stat.permissions +& 0o4000);
+ }
+
+ multi method g() {
+ ?($.stat.permissions +& 0o2000);
+ }
+
+ multi method k() {
+ ?($.stat.permissions +& 0o1000);
+ }
+
multi method z() {
$.e && $.s == 0;
}
--
1.7.3.4
|
From @moritzThis has auld lang sine been applied, thanks for the patch, closing |
@moritz - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#84966 (status was 'resolved')
Searchable as RT84966$
The text was updated successfully, but these errors were encountered: