prev - up - next - index

Dir

The class for the directory stream.

SuperClass:

Object

Included Modules:

Enumerable

Class Methods:

self[pattern]
glob(pattern)

Expands a wild-card pattern, then returns the results in an array of strings.

Wild-cards are:

*
Matches any string, including the null string
?
Matches any single character
[ ]
Matches any one of enclosed character. A pair of characters separated by a `-' sign denotes a range. If the first character following `[' is a `^', then any character not enclosed is matched.
{ }
Expanded to combinations of comma separating string within braces. For example, `foo{a,b,c}' will be expanded into three strings, `fooa', `foob', `fooc'. The generated names need not to be exist.
chdir(path)

Changes the current directory to the path.

chroot(path)

Changes the root directory to path. See chroot(2). Only the super-user may change the root directory

There is no way to back up the old root directory.

getwd
pwd

Returns the absolute pathname of the current directory.

foreach(path)

iterates over the items in the directory specified by path. It works like:

dir = Dir.open(path)
begin
  dir.each {
    ...
  }
ensure
  dir.close
end

mkdir(path[, mode])

Creates a directory named path. the permission of a newly created directory specified by mode. The default mode is 0777, which will be modified by users umask (mode & ~umask).

open(path)

Opens the directory stream corresponding to the directory path.

delete(path)
rmdir(path)
unlink(path)

Deletes the directory, which must be empty.

Methods:

close

Closes the directory stream. Later operation to the directory stream raises an exception.

each {|item|...}

Gives each item in the directory as the block parameter.

read

Returns the next item in the directory stream.

rewind

Resets the position of the directory stream to the beginning of the directory.

seek(pos)

Sets the location of the directory stream to the pos. The pos must be an offset returned by Dir#tell.

tell

Returns the current position of the directory stream.


prev - up - next - index

matz@netlab.co.jp