Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.0.2: return more permissions in shortflag form
- Loading branch information
Andy Weidenbaum
committed
Aug 17, 2016
1 parent
1684e3c
commit d0c5cb5
Showing
4 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
use v6; | ||
unit class File::Presence; | ||
|
||
constant $VERSION = v0.0.1; | ||
constant $VERSION = v0.0.2; | ||
|
||
subset PresenceHash of Hash where { .keys.sort ~~ <dir exists file readable> } | ||
subset PresenceHash of Hash where { .keys.sort ~~ <d e f r w x> } | ||
|
||
method show(Str $file) returns PresenceHash | ||
{ | ||
my Bool $e = $file.IO.e; | ||
my Bool $d = False; | ||
my Bool $f = False; | ||
my Bool $r = False; | ||
my Bool $w = False; | ||
my Bool $x = False; | ||
|
||
if $e | ||
{ | ||
$d = $file.IO.d; | ||
$f = $file.IO.f; | ||
$r = $file.IO.r; | ||
$w = $file.IO.w; | ||
$x = $file.IO.x; | ||
} | ||
|
||
my PresenceHash $p = %(:dir($d), :exists($e), :file($f), :readable($r)); | ||
my PresenceHash $p = %(:$d, :$e, :$f, :$r, :$w, :$x); | ||
} | ||
|
||
sub exists-readable-dir(Str $dir) is export returns Bool | ||
{ | ||
my PresenceHash $p = File::Presence.show($dir); | ||
$p<exists> && $p<readable> && $p<dir>; | ||
$p<e> && $p<r> && $p<d>; | ||
} | ||
|
||
sub exists-readable-file(Str $file) is export returns Bool | ||
{ | ||
my PresenceHash $p = File::Presence.show($file); | ||
$p<exists> && $p<readable> && $p<file>; | ||
$p<e> && $p<r> && $p<f>; | ||
} | ||
|
||
# vim: ft=perl6 fdm=marker fdl=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters