简体   繁体   中英

Read Windows Folder/File-Permissions with Ruby

I would like to get a list of Folder-Permissions in Ruby. As input i give eg 'c://temp' and output should be, which user/group has rights and which rights.

and the next thing is to pass a second parameter (user or group) so that ruby can tell me on which folder this group or user has rights (reading / writing etc.).

cant find anything and get_permissions from win32-file-gem doesn't work.

thank in advance for any help.

Try to use win32-file-stat gem. For example:

require 'win32/file/stat'
f = File::Stat.new("c:/temp")
p f

will give you something like this:

#<File::Stat archive=false atime=1970-01-01 04:00:00 +0400 blksize=4096 blockdev=false blocks=0 compressed=false ctime=1970-01-01 04:00:00 +0400 dev=C: encrypted=false gid=0 hidden=false indexed=true ino=0 mode=040755 mtime=1970-01-01 04:00:00 +0400 nlink=1 normal=false offline=false rdev=2 readonly=false reparse_point=false size=0 sparse=false system=false temporary=false uid=0

where you could see mode , gid and uid as numbers, accessed by `f.mode , f.gid and f.uid respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM