[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/05: L::Path: Add is_{read,writ,execut}able methods



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit ce32160af2f02309446266882d5a0e7d4061b35c
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Sep 28 15:54:56 2014 +0200

    L::Path: Add is_{read,writ,execut}able methods
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Path.pm      | 26 ++++++++++++++++++++++++++
 t/scripts/pod-spelling.t |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/Lintian/Path.pm b/lib/Lintian/Path.pm
index f7d4b26..1ba984a 100644
--- a/lib/Lintian/Path.pm
+++ b/lib/Lintian/Path.pm
@@ -315,6 +315,32 @@ sub link_normalized {
     return $target;
 }
 
+=item is_readable
+
+Returns a truth value if the permission bits of this entry have
+at least one bit denoting readability set (bitmask 0444).
+
+=item is_writable
+
+Returns a truth value if the permission bits of this entry have
+at least one bit denoting writability set (bitmask 0222).
+
+=item is_executable
+
+Returns a truth value if the permission bits of this entry have
+at least one bit denoting executability set (bitmask 0111).
+
+=cut
+
+sub _any_bit_in_operm {
+    my ($self, $bitmask) = @_;
+    return ($self->operm & $bitmask) ? 1 : 0;
+}
+
+sub is_readable   { return $_[0]->_any_bit_in_operm(0444); }
+sub is_writable   { return $_[0]->_any_bit_in_operm(0222); }
+sub is_executable { return $_[0]->_any_bit_in_operm(0111); }
+
 =item fs_path
 
 Returns the path to this object on the file system.
diff --git a/t/scripts/pod-spelling.t b/t/scripts/pod-spelling.t
index 54a77ef..ba340fb 100755
--- a/t/scripts/pod-spelling.t
+++ b/t/scripts/pod-spelling.t
@@ -115,7 +115,7 @@ Whitespace udebs multiword recognised eqv testsuite methodx multi
 multiarch relationA relationB Multi natively unordered arg CVE autodie
 hashrefs namespace subdir SIGPIPE SIG blocknumber blocksub readwindow
 REMOVESLASH STAMPFILE TAGNAME TCODE TESTDATA BLOCKSIZE jN
-POSIX t1c2pfb init runtime txt
+POSIX t1c2pfb init runtime txt executability writability
 
 __END__
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: