Skip to content

Commit

Permalink
Implement IO.l-* methods as in S16-io (newio)
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Feb 13, 2015
1 parent 0a42459 commit 688e218
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
9 changes: 9 additions & 0 deletions src/core/IO/Dup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ class IO::Dup does IO does PIO {
method changed(IO::Dup:D:) { Instant }
method device(IO::Dup:D:) { 0 }
method inode(IO::Dup:D:) { 0 }

method l-e(IO::Dup:D:) { True }
method l-s(IO::Dup:D:) { 0 }

method l-modified(IO::Dup:D:) { Instant }
method l-accessed(IO::Dup:D:) { Instant }
method l-changed(IO::Dup:D:) { Instant }
method l-device(IO::Dup:D:) { 0 }
method l-inode(IO::Dup:D:) { 0 }
}

PROCESS::<$ERR> = IO::Dup.new( :fileno(2) );
Expand Down
8 changes: 8 additions & 0 deletions src/core/IO/Pathy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ my role IO::Pathy {
method device(IO::Pathy:D:) { FILETEST-DEVICE( $!abspath) }
method inode(IO::Pathy:D:) { FILETEST-INODE( $!abspath) }

method l-e(IO::Pathy:D:) { True }
method l-s(IO::Pathy:D:) { FILETEST-ls( $!abspath) }
method l-modified(IO::Pathy:D:) { FILETEST-LMODIFIED($!abspath) }
method l-accessed(IO::Pathy:D:) { FILETEST-LACCESSED($!abspath) }
method l-changed(IO::Pathy:D:) { FILETEST-LCHANGED( $!abspath) }
method l-device(IO::Pathy:D:) { FILETEST-LDEVICE( $!abspath) }
method l-inode(IO::Pathy:D:) { FILETEST-LINODE( $!abspath) }

method rename(IO::Pathy:D: Str() $to, :$createonly) {
my $topath := MAKE-ABSOLUTE-PATH($to,$*CWD.Str);
RENAME-PATH($!abspath,$topath,:$createonly);
Expand Down
47 changes: 33 additions & 14 deletions src/core/IOU.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ my class IOU does IO::Pathy {
# at creation time. We try to create the object again, call the method if
# succeeds, or fail. Wish there were a less verbose way to do this.

method e(IOU:D:) { self!that ?? $!that.e !! self!fail('e') }
method f(IOU:D:) { self!that ?? $!that.f !! self!fail('f') }
method d(IOU:D:) { self!that ?? $!that.d !! self!fail('d') }
method s(IOU:D:) { self!that ?? $!that.s !! self!fail('s') }
method l(IOU:D:) { self!that ?? $!that.l !! self!fail('l') }
method r(IOU:D:) { self!that ?? $!that.r !! self!fail('r') }
method w(IOU:D:) { self!that ?? $!that.w !! self!fail('w') }
method rw(IOU:D:) { self!that ?? $!that.rw !! self!fail('rw') }
method x(IOU:D:) { self!that ?? $!that.x !! self!fail('x') }
method rx(IOU:D:) { self!that ?? $!that.rx !! self!fail('rx') }
method wx(IOU:D:) { self!that ?? $!that.wx !! self!fail('wx') }
method rwx(IOU:D:) { self!that ?? $!that.rwx !! self!fail('rwx') }
method o(IOU:D:) { self!that ?? $!that.o !! self!fail('o') }
method z(IOU:D:) { self!that ?? $!that.z !! self!fail('z') }
method e(IOU:D:) { self!that ?? $!that.e !! self!fail('e') }
method f(IOU:D:) { self!that ?? $!that.f !! self!fail('f') }
method d(IOU:D:) { self!that ?? $!that.d !! self!fail('d') }
method s(IOU:D:) { self!that ?? $!that.s !! self!fail('s') }
method l(IOU:D:) { self!that ?? $!that.l !! self!fail('l') }
method r(IOU:D:) { self!that ?? $!that.r !! self!fail('r') }
method w(IOU:D:) { self!that ?? $!that.w !! self!fail('w') }
method rw(IOU:D:) { self!that ?? $!that.rw !! self!fail('rw') }
method x(IOU:D:) { self!that ?? $!that.x !! self!fail('x') }
method rx(IOU:D:) { self!that ?? $!that.rx !! self!fail('rx') }
method wx(IOU:D:) { self!that ?? $!that.wx !! self!fail('wx') }
method rwx(IOU:D:) { self!that ?? $!that.rwx !! self!fail('rwx') }
method o(IOU:D:) { self!that ?? $!that.o !! self!fail('o') }
method z(IOU:D:) { self!that ?? $!that.z !! self!fail('z') }

method modified(IOU:D:) {
self!that ?? $!that.modified !! self!fail('modified');
Expand All @@ -75,6 +75,25 @@ my class IOU does IO::Pathy {
self!that ?? $!that.inode !! self!fail('inode');
}

method l-e(IOU:D:) { self!that ?? $!that.l-e !! self!fail('l-e') }
method l-s(IOU:D:) { self!that ?? $!that.l-s !! self!fail('l-s') }

method l-modified(IOU:D:) {
self!that ?? $!that.l-modified !! self!fail('l-modified');
}
method l-accessed(IOU:D:) {
self!that ?? $!that.l-accessed !! self!fail('l-accessed');
}
method l-changed(IOU:D:) {
self!that ?? $!that.l-changed !! self!fail('l-changed');
}
method l-device(IOU:D:) {
self!that ?? $!that.l-device !! self!fail('l-device');
}
method l-inode(IOU:D:) {
self!that ?? $!that.l-inode !! self!fail('l-inode');
}

# private methods

method !that(IOU:D:) { $!that //= self!what($!abspath,|$!rest) }
Expand Down

0 comments on commit 688e218

Please sign in to comment.