Skip to content
A redefinition of Ruby's File::Stat class for MS Windows
Branch: ffi2
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


== Description
  A redefinition of the File::Stat class for MS Windows.

== Prerequisites
  * ffi
  * Ruby 1.9 or later

== Installation
  gem install win32-file-stat

== Synopsis
  # require 'win32/file/stat' # Unwise. See below.
  require 'win32/file' # Preferred. See below.

  stat ='file.txt')
  p stat.size
  p stat.readonly?
  p stat.hidden?
  p stat.uid 
  p stat.streams

== Differences between Ruby's File::Stat and this version:
  * The File::Stat#blksize method returns a meaningful value.
  * The File::Stat#blockdev method works more accurately.
  * The File::Stat#blocks method returns a meaningful value.
  * The File::Stat#executable? method works properly.
  * The File::Stat#executable_real? is an alias for File::Stat#executable?
  * The File::Stat#file? method works properly.
  * The File::Stat#ftype method works more accurately.
  * The File::Stat#pipe method works properly.
  * The File::Stat#socket method works more accurately.
  * The File::Stat#ino method now returns a file identifier.
  * The File::Stat#socket? method works properly.
  * The File::Stat#symlink? method works properly.
  * The File::Stat#uid method returns a meaningful value.
  * The File::Stat#gid method returns a meaningful value.
  * The File::Stat#owned? method now works properly.
  * The File::Stat#grpowned? method now works properly.
  * The File::Stat#rdev method returns the volume serial number.
  * The inspect and pretty print output has been customized.
  * The File::Stat#streams was added. Returns an array of alt streams.

== Changes between this version and the previous versions.
  The File::Stat#dev method has reverted to returning a drive number by
  default. However, you can pass an optional boolean argument to make it
  return the drive letter instead.
== Known issues
  You should not require 'win32/file/stat' directly. Instead, require the
  win32-file library which will, in turn, require win32-file-stat. This is
  the preferred approach because some modules (i.e. 'find') use the pass-through
  methods of the File class, such as File.lstat.  Many of the pass through
  methods have been redefined in the win32-file library to work in conjunction
  with the custom File::Stat objects created by this library.

  Failure to follow these instructions could lead to cases where the core Ruby
  File class attempts to use the custom File::Stat object defined in this class,
  and that will likely cause problems.

  If run in verbose mode you will see a warning about initialize being
  redefined. I can do nothing about that since my old trick of aliasing and
  undefining initialize now causes a warning as well!

== Known bugs
  None that I'm aware of beyond the "Known Issues" listed above. Please report
  any bugs you find on the project page at:

== Miscellaneous
  I had to require 'pp' explicitly in order to deal with the fact that pp.rb
  has a builtin pretty_print method for File::Stat. If I didn't do this
  you would end up using the pretty_print in pp.rb, which would break.

== Contributions
  Although this library is free, please consider having your company
  setup a gittip if used by your company professionally.

== Copyright
  (C) 2003-2016, Daniel J. Berger, All Rights Reserved.

== License
  Artistic 2.0

= Warranty
  This library is provided "as is" and without any express or
  implied warranties, including, without limitation, the implied
  warranties of merchantability and fitness for a particular purpose.

= Authors
  Daniel J. Berger
  Park Heesob
You can’t perform that action at this time.