#731: can't tell if an OS file is executable from parrot
--------------------+-------------------------------------------------------
Reporter: coke | Owner:
Type: todo | Status: new
Priority: normal | Milestone:
Component: none | Version:
Severity: medium | Keywords: tcl blocker
Lang: tcl | Patch:
Platform: |
--------------------+-------------------------------------------------------
Comment(by coke):
Here's a sample that works for "o+x", but not "g+x" or "u+x" (for those, I
need to know if I am the file owner, or if I'm in the group that is
associated with the file.
{{{
.sub 'foo'
$I0 = is_executable('parrot')
say $I0
$I0 = is_executable('MANIFEST')
say $I0
.end
.sub is_executable
.param string filename
# not exported from C to PIR
.local int STAT_PLATFORM_MODE
STAT_PLATFORM_MODE = -3
.local int UID
UID = 9
.local int mode
mode = stat filename, STAT_PLATFORM_MODE
.local int check_mode
# is this executable by anyone?
check_mode = band mode, 1
if check_mode goto true
# is this executable by the owner?
check_mode = band mode, 64
.local int file_uid
file_uid = stat filename, UID
.local int my_uid
# XXX what's my effective UID?
# is this executable by a group?
check_mode = band mode, 8
# XXX am I in that group?
# If we got this far, it's not executable
.return(0)
# Standard modes
true:
.return(1)
.end
}}}
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/731#comment:4>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets