Git Product home page Git Product logo

mruby-file-stat's Introduction

mruby-file-stat

CI

File::Stat class in mruby

stat = File::Stat.new('filename') # or File.stat('filename')
stat.dev #=> device id
stat.dev_major #=> device major id
stat.dev_minor #=> device minor id
stat.ino #=> i-node number
stat.mode #=> permission value (st_mode)
stat.nlink #=> hard link count
stat.uid #=> user id
stat.gid #=> group id
stat.rdev #=> device type
stat.rdev_major #=> rdev major id
stat.rdev_minor #=> rdev minor id
stat.atime #=> last access time
stat.mtime #=> last modify time
stat.ctime #=> last change attribute time
stat.birthtime #=> file created time
stat.size #=> file size(byte)
stat.blksize #=> file I/O block size
stat.blocks #=> attached block num
stat.grpowned #=> same gid?
stat.<=> #=> comparate mtime (-1,0,1 or nil)
stat.size?
stat.zero?
stat.symlink?
stat.file?
stat.directory?
stat.chardev?
stat.blockdev?
stat.pipe?
stat.socket?
stat.owned?
stat.owned_real?
stat.readable?
stat.readable_real?
stat.writable?
stat.writable_real?
stat.executable?
stat.executable_real?
stat.world_readable?
stat.world_writable?
stat.setuid?
stat.setgid?
stat.sticky?
stat.ftype #=> socket, link, file, blockSpecial, directory, characterSpecial, fifo or unknown

This library is wrap of struct stat.

Installation

use github repository

Write in /mruby/build_config.rb

MRuby::Build.new do |conf|
  # by mgem
  conf.gem :mgem => 'mruby-file-stat'
  # by github
  conf.gem :github => 'ksss/mruby-file-stat', :branch => 'master'
end

Homepage

https://github.com/ksss/mruby-file-stat

License

See https://github.com/ruby/ruby/blob/trunk/file.c

Doc

http://ruby-doc.org/core-2.1.5/File/Stat.html

mruby-file-stat's People

Contributors

k0kubun avatar kazuho avatar kou avatar ksss avatar lutter avatar masahino avatar okkez avatar takahashim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mruby-file-stat's Issues

Stat isn't working properly with symlinks.

I have the following code.

destination = File.expand_path "~/.spacemacs"
if File.exists?(destination)
  s = File.stat(destination)
  puts s.ftype
  puts s.symlink?
  puts File.realpath(destination)
  puts File.readlink(destination)
end

This gives a very unexpected output

file
false
/opt/tim/dorkish/x1/dotfiles/spacemacs/.spacemacs
dorkish/x1/dotfiles/spacemacs/.spacemacs

The filetype is being reported as "file" and it should be "link"
the realpath call returns the full path of the real file and the readlink returns the relative path of the real fie.

I am not sure what is going on here but clearly both the filetype and the symlink? calls are returning unexpected values.

birthtime raises error

if I copy and paste your example code stat.birthtime raises a method not found exception.

Remove dependency on mkmf

Why

  • It needs ruby.h
  • Old ruby's mkmf have some bugs

So, I want to remove dependency on mkmf.
Does anyone have a good idea?

Candidates

  • cmake

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.