Dir

Class Methods

Dir.new

Now behaves like Dir.open in that it takes a block and automatically closes the handle.

Dir.open

This is now an alias for Dir.new, which itself adopted the original Dir.open semantics.

Dir.tmpdir

This is now a core method. The tmpdir library has been removed.

This method returns the path found in your TMP, TEMP, USERPROFILE environment variable, in that order. If it cannot be found, it resorts to '/tmp' (Unix) or you Windows directory (Windows), e.g. C:\WINNT\Temp.

Unlike Ruby, it does not check 'TMPDIR' (no one sets this), does not alter its behavior based on $SAFE (I'm going to scrap $SAFE), does not default to the current directory (bad idea), and does not verify whether or not the directory exists, that it really is a directory, or if the directory is writable. That's your job.

Instance Methods

Dir#closed?

This is a new method that simply tells you if the directory stream is closed or not. Analogous to IO#closed? and handy for testing to boot.

Dir#inspect

There is a custom implementation in dir.c, but Ruby isn't using it. Sapphire does.

Also available in: HTML TXT