README

Path: README
Last Update: Fri Dec 14 11:49:37 -0300 2007

Description

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

Prerequisites

  • Ruby 1.8.0 or later.
  • windows-pr 0.6.0 or later.

Installation

rake install (non-gem) OR rake install_gem (gems)

Synopsis

   # Don't 'require' like this in practice - see 'Known Issues' below
   require 'win32/file/stat'

   stat = File::Stat.new('file.txt')
   stat.size
   stat.readonly?
   stat.hidden?

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#dev method returns a drive letter, not a number.
  • The File::Stat#executable? method works properly.
  • The File::Stat#executable_real? returns the same value as File::Stat#executable? (which now works properly).
  • 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#size method handles file sizes greater than 2 gigabytes correctly.
  • The File::Stat#socket method works more accurately.
  • Allows you to get file attributes specific to MS Windows, e.g. archive, hidden, etc.
  • The pp (pretty print) output has been customized.

Known issues

You should not require ‘win32/file/stat’ directly. Instead, require the win32-file package 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 package to work in conjunction with the custom File::Stat objects created by this package.

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, which will likely cause problems.

Known bugs

None that I‘m aware of. Please report any bugs you find on the project page at www.rubyforge.org/projects/win32utils.

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.

License

Ruby‘s

Warranty

This package 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.

Author

Daniel J. Berger

[Validate]