Class: File::Stat
- Inherits:
-
Object
- Object
- File::Stat
- Defined in:
- lib/opal-file/stat.rb
Class Method Summary collapse
Instance Method Summary collapse
- #atime ⇒ Object
- #birthtime ⇒ Object
- #blksize ⇒ Object
- #blockdev? ⇒ Boolean
- #blocks ⇒ Object
- #chardev? ⇒ Boolean
- #ctime ⇒ Object
- #dev ⇒ Object
- #dev_major ⇒ Object
- #dev_minor ⇒ Object
- #directory? ⇒ Boolean
- #executable? ⇒ Boolean
- #executable_real? ⇒ Boolean
- #file? ⇒ Boolean
- #ftype ⇒ Object
- #gid ⇒ Object
- #grpowned? ⇒ Boolean
-
#initialize(path) ⇒ Stat
constructor
A new instance of Stat.
- #ino ⇒ Object
- #mode ⇒ Object
- #mtime ⇒ Object
- #nlink ⇒ Object
- #owned? ⇒ Boolean
- #pipe? ⇒ Boolean
- #rdev ⇒ Object
- #rdev_major ⇒ Object
- #rdev_minor ⇒ Object
- #readable? ⇒ Boolean
- #readable_real? ⇒ Boolean
- #setgid? ⇒ Boolean
- #setuid? ⇒ Boolean
- #size ⇒ Object
- #size? ⇒ Boolean
- #socket? ⇒ Boolean
- #sticky? ⇒ Boolean
- #symlink? ⇒ Boolean
- #uid ⇒ Object
- #world_readable? ⇒ Boolean
- #world_writable? ⇒ Boolean
- #writable? ⇒ Boolean
- #writable_real? ⇒ Boolean
- #zero? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Stat
Returns a new instance of Stat.
25 26 27 28 29 30 31 32 |
# File 'lib/opal-file/stat.rb', line 25 def initialize(path) if `typeof path === "string"` @stat = File::Stat.stat_sync(path) raise Class.const_get("Errno::#{@stat}") if `typeof this.stat === "string"` else @stat = path end end |
Class Method Details
.from_lstat(path) ⇒ Object
10 11 12 |
# File 'lib/opal-file/stat.rb', line 10 def from_lstat(path) File::Stat.new(File::Stat.lstat_sync(path)) end |
.lstat_sync(file) ⇒ Object
19 20 21 22 |
# File 'lib/opal-file/stat.rb', line 19 def lstat_sync(file) e = nil `try { return require("fs").lstatSync(file) } catch (#{e}) { #{raise Class.const_get("Errno::#{e.JS[:code]}")} }` end |
.stat_sync(file) ⇒ Object
14 15 16 17 |
# File 'lib/opal-file/stat.rb', line 14 def stat_sync(file) e = nil `try { return require("fs").statSync(file) } catch(#{e}) { #{raise Class.const_get("Errno::#{e.JS[:code]}")} }` end |
Instance Method Details
#atime ⇒ Object
34 35 36 |
# File 'lib/opal-file/stat.rb', line 34 def atime ms_to_time @stat.JS[:atimeMs] end |
#birthtime ⇒ Object
38 39 40 |
# File 'lib/opal-file/stat.rb', line 38 def birthtime ms_to_time @stat.JS[:birthtimeMs] end |
#blksize ⇒ Object
42 43 44 |
# File 'lib/opal-file/stat.rb', line 42 def blksize @stat.JS[:blksize] end |
#blockdev? ⇒ Boolean
46 47 48 |
# File 'lib/opal-file/stat.rb', line 46 def blockdev? @stat.JS.isBlockDevice() end |
#blocks ⇒ Object
50 51 52 |
# File 'lib/opal-file/stat.rb', line 50 def blocks @stat.JS[:blocks] end |
#chardev? ⇒ Boolean
54 55 56 |
# File 'lib/opal-file/stat.rb', line 54 def chardev? @stat.JS.isCharacterDevice() end |
#ctime ⇒ Object
58 59 60 |
# File 'lib/opal-file/stat.rb', line 58 def ctime ms_to_time @stat.JS[:ctimeMs] end |
#dev ⇒ Object
62 63 64 |
# File 'lib/opal-file/stat.rb', line 62 def dev @stat.JS[:dev] end |
#dev_major ⇒ Object
66 67 68 |
# File 'lib/opal-file/stat.rb', line 66 def dev_major raise NotImplementedError end |
#dev_minor ⇒ Object
70 71 72 |
# File 'lib/opal-file/stat.rb', line 70 def dev_minor raise NotImplementedError end |
#directory? ⇒ Boolean
74 75 76 |
# File 'lib/opal-file/stat.rb', line 74 def directory? @stat.JS.isDirectory() end |
#executable? ⇒ Boolean
78 79 80 |
# File 'lib/opal-file/stat.rb', line 78 def executable? raise NotImplementedError end |
#executable_real? ⇒ Boolean
82 83 84 |
# File 'lib/opal-file/stat.rb', line 82 def executable_real? raise NotImplementedError end |
#file? ⇒ Boolean
86 87 88 |
# File 'lib/opal-file/stat.rb', line 86 def file? @stat.JS.isFile() end |
#ftype ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/opal-file/stat.rb', line 90 def ftype if file? then "file" elsif directory? then "directory" elsif chardev? then "characterSpecial" elsif blockdev? then "blockSpecial" elsif pipe? then "fifo" elsif symlink? then "link" elsif socket? then "socket" else "unknown" end end |
#gid ⇒ Object
102 103 104 |
# File 'lib/opal-file/stat.rb', line 102 def gid @stat.JS[:gid] end |
#grpowned? ⇒ Boolean
106 107 108 |
# File 'lib/opal-file/stat.rb', line 106 def grpowned? raise NotImplementedError end |
#ino ⇒ Object
110 111 112 |
# File 'lib/opal-file/stat.rb', line 110 def ino @stat.JS[:ino] end |
#mode ⇒ Object
114 115 116 |
# File 'lib/opal-file/stat.rb', line 114 def mode @stat.JS[:mode] end |
#mtime ⇒ Object
118 119 120 |
# File 'lib/opal-file/stat.rb', line 118 def mtime ms_to_time @stat.JS[:mtimeMs] end |
#nlink ⇒ Object
122 123 124 |
# File 'lib/opal-file/stat.rb', line 122 def nlink @stat.JS[:nlink] end |
#owned? ⇒ Boolean
126 127 128 |
# File 'lib/opal-file/stat.rb', line 126 def owned? raise NotImplementedError end |
#pipe? ⇒ Boolean
130 131 132 |
# File 'lib/opal-file/stat.rb', line 130 def pipe? @stat.JS.isFIFO() end |
#rdev ⇒ Object
134 135 136 |
# File 'lib/opal-file/stat.rb', line 134 def rdev @stat.JS[:rdev] end |
#rdev_major ⇒ Object
138 139 140 |
# File 'lib/opal-file/stat.rb', line 138 def rdev_major raise NotImplementedError end |
#rdev_minor ⇒ Object
142 143 144 |
# File 'lib/opal-file/stat.rb', line 142 def rdev_minor raise NotImplementedError end |
#readable? ⇒ Boolean
146 147 148 |
# File 'lib/opal-file/stat.rb', line 146 def readable? raise NotImplementedError end |
#readable_real? ⇒ Boolean
150 151 152 |
# File 'lib/opal-file/stat.rb', line 150 def readable_real? raise NotImplementedError end |
#setgid? ⇒ Boolean
154 155 156 |
# File 'lib/opal-file/stat.rb', line 154 def setgid? raise NotImplementedError end |
#setuid? ⇒ Boolean
158 159 160 |
# File 'lib/opal-file/stat.rb', line 158 def setuid? raise NotImplementedError end |
#size ⇒ Object
162 163 164 |
# File 'lib/opal-file/stat.rb', line 162 def size @stat.JS[:size] end |
#size? ⇒ Boolean
166 167 168 169 |
# File 'lib/opal-file/stat.rb', line 166 def size? _size = size _size == 0 ? nil : _size end |
#socket? ⇒ Boolean
171 172 173 |
# File 'lib/opal-file/stat.rb', line 171 def socket? @stat.JS.isSocket() end |
#sticky? ⇒ Boolean
175 176 177 |
# File 'lib/opal-file/stat.rb', line 175 def sticky? mode & 0001000; end |
#symlink? ⇒ Boolean
179 180 181 |
# File 'lib/opal-file/stat.rb', line 179 def symlink? @stat.JS.isSymbolicLink() end |
#uid ⇒ Object
183 184 185 |
# File 'lib/opal-file/stat.rb', line 183 def uid @stat.JS[:uid] end |
#world_readable? ⇒ Boolean
187 188 189 |
# File 'lib/opal-file/stat.rb', line 187 def world_readable? raise NotImplementedError end |
#world_writable? ⇒ Boolean
191 192 193 |
# File 'lib/opal-file/stat.rb', line 191 def world_writable? raise NotImplementedError end |
#writable? ⇒ Boolean
195 196 197 |
# File 'lib/opal-file/stat.rb', line 195 def writable? raise NotImplementedError end |
#writable_real? ⇒ Boolean
199 200 201 |
# File 'lib/opal-file/stat.rb', line 199 def writable_real? raise NotImplementedError end |
#zero? ⇒ Boolean
203 204 205 |
# File 'lib/opal-file/stat.rb', line 203 def zero? size == 0 end |