| 1 |
# mruby-file-stat |
| 2 |
|
| 3 |
[](https://github.com/ksss/mruby-file-stat/actions) |
| 4 |
|
| 5 |
**File::Stat** class in mruby |
| 6 |
|
| 7 |
```ruby |
| 8 |
stat = File::Stat.new('filename') # or File.stat('filename') |
| 9 |
stat.dev #=> device id |
| 10 |
stat.dev_major #=> device major id |
| 11 |
stat.dev_minor #=> device minor id |
| 12 |
stat.ino #=> i-node number |
| 13 |
stat.mode #=> permission value (st_mode) |
| 14 |
stat.nlink #=> hard link count |
| 15 |
stat.uid #=> user id |
| 16 |
stat.gid #=> group id |
| 17 |
stat.rdev #=> device type |
| 18 |
stat.rdev_major #=> rdev major id |
| 19 |
stat.rdev_minor #=> rdev minor id |
| 20 |
stat.atime #=> last access time |
| 21 |
stat.mtime #=> last modify time |
| 22 |
stat.ctime #=> last change attribute time |
| 23 |
stat.birthtime #=> file created time |
| 24 |
stat.size #=> file size(byte) |
| 25 |
stat.blksize #=> file I/O block size |
| 26 |
stat.blocks #=> attached block num |
| 27 |
stat.grpowned #=> same gid? |
| 28 |
stat.<=> #=> comparate mtime (-1,0,1 or nil) |
| 29 |
stat.size? |
| 30 |
stat.zero? |
| 31 |
stat.symlink? |
| 32 |
stat.file? |
| 33 |
stat.directory? |
| 34 |
stat.chardev? |
| 35 |
stat.blockdev? |
| 36 |
stat.pipe? |
| 37 |
stat.socket? |
| 38 |
stat.owned? |
| 39 |
stat.owned_real? |
| 40 |
stat.readable? |
| 41 |
stat.readable_real? |
| 42 |
stat.writable? |
| 43 |
stat.writable_real? |
| 44 |
stat.executable? |
| 45 |
stat.executable_real? |
| 46 |
stat.world_readable? |
| 47 |
stat.world_writable? |
| 48 |
stat.setuid? |
| 49 |
stat.setgid? |
| 50 |
stat.sticky? |
| 51 |
stat.ftype #=> socket, link, file, blockSpecial, directory, characterSpecial, fifo or unknown |
| 52 |
``` |
| 53 |
|
| 54 |
This library is wrap of struct stat. |
| 55 |
|
| 56 |
## Installation |
| 57 |
|
| 58 |
### use github repository |
| 59 |
|
| 60 |
Write in /mruby/build_config.rb |
| 61 |
|
| 62 |
```ruby |
| 63 |
MRuby::Build.new do |conf| |
| 64 |
# by mgem |
| 65 |
conf.gem :mgem => 'mruby-file-stat' |
| 66 |
# by github |
| 67 |
conf.gem :github => 'ksss/mruby-file-stat', :branch => 'master' |
| 68 |
end |
| 69 |
``` |
| 70 |
|
| 71 |
## Homepage |
| 72 |
|
| 73 |
https://github.com/ksss/mruby-file-stat |
| 74 |
|
| 75 |
## License |
| 76 |
|
| 77 |
See [https://github.com/ruby/ruby/blob/trunk/file.c](https://github.com/ruby/ruby/blob/trunk/file.c) |
| 78 |
|
| 79 |
## Doc |
| 80 |
|
| 81 |
[http://ruby-doc.org/core-2.1.5/File/Stat.html](http://ruby-doc.org/core-2.1.5/File/Stat.html) |