HTTPS clone URL
Subversion checkout URL
Clone this wiki locally
The win32-dir library provides additional constants and methods for the core Dir class that are specific to MS Windows. In addition, some core methods have been redefined to be more Windows friendly.
When you first load win32-dir a series of constants are dynamically generated. This is a one-time cost. The values for these constants are filesystem paths for various system paths that the operating system defines.
These constants should be preferred over hard coded strings. For example, the system directory on a Windows system might be C:\Windows, C:\Win32 or C:\WinNT. Instead of making an assumption about which directory it might be, use the Dir::WINDOWS constant:
require 'win32/dir' puts Dir::WINDOWS # => "C:\\Windows"
See the documentation for a list of available constants.
The win32-dir library adds the following singleton methods:
Lets you create a junction (similar to a symlink, but for directories only)
Is the directory empty?
Is the directory a junction?
Alias for Dir.junction?
This method is nearly identical to the core method. Unlike MRI, however, it returns a normalized path.
require 'win32/dir' Dir.chdir("C:/Progra~1") Dir.getwd # => C:\Program Files Dir.chdir("C:/PROGRAM FILES") Dir.getwd # => C:\Program Files