1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
module Platform
module Stat
class Stat < FFI::Struct
@@@
struct do |s|
s.include "sys/types.h"
s.include "sys/stat.h"
s.name "struct stat"
s.field :st_dev, :dev_t
s.field :st_ino, :ino_t
s.field :st_nlink, :nlink_t
s.field :st_mode, :mode_t
s.field :st_uid, :uid_t
s.field :st_gid, :gid_t
s.field :st_size, :off_t
s.field :st_blocks, :blkcnt_t
s.field :st_atime, :time_t
s.field :st_mtime, :time_t
s.field :st_ctime, :time_t
end
@@@
end
module Constants
@@@
constants do |cg|
cg.include "sys/types.h"
cg.include "sys/stat.h"
%w[
S_ISUID
S_ISGID
S_IRUSR
S_IWUSR
S_IXUSR
S_IRWXU
S_IREAD
S_IWRITE
S_IEXEC
S_IRGRP
S_IWGRP
S_IXGRP
S_IRWXG
S_IROTH
S_IWOTH
S_IXOTH
S_IRWXO
].each {|c| cg.const(c, "%#x", "(unsigned int)") }
end
@@@
end
include Constants
end
end
|