11.10. Directory handling functions

11.10.1. Dir

A Directory object, as well as associated functions.

11.10.1.1. Dir.make(name)

Creates a directory.

The created directory is set for permission mode 0755 (octal), meaning it is read+write+execute by owner, but only read+execute by group and others.

IF the directory was created successfully, a boolean true is returned. If the directory cannot be made because it already exists, false is returned. If the directory cannot be made because an error occurred, nil is returned.

Since: 1.11.3

Arguments
name
The name of the directory, possibly including path.
Returns

Boolean true on success, false if already exists, nil on error.

11.10.1.2. Dir.exists(name)

Returns true if the given directory name exists.

If the directory exists, a boolean true is returned. If the path is a file instead, false is returned. If the path does not exist or an error occurred, nil is returned.

Since: 1.11.3

Arguments
name
The name of the directory, possibly including path.
Returns

Boolean true if the directory exists, false if it’s a file, nil on error/not-exist.

11.10.1.3. Dir.remove(name)

Removes an empty directory.

If the directory was removed successfully, a boolean true is returned. If the directory cannot be removed because it does not exist, false is returned. If the directory cannot be removed because an error occurred, nil is returned.

This function only removes empty directories. To remove a directory regardless, use Dir.remove_all().

Since: 1.11.3

Arguments
name
The name of the directory, possibly including path.
Returns

Boolean true on success, false if does not exist, nil on error.

11.10.1.4. Dir.remove_all(name)

Removes an empty or non-empty directory.

If the directory was removed successfully, a boolean true is returned. If the directory cannot be removed because it does not exist, false is returned. If the directory cannot be removed because an error occurred, nil is returned.

Since: 1.11.3

Arguments
name
The name of the directory, possibly including path.
Returns

Boolean true on success, false if does not exist, nil on error.

11.10.1.5. Dir.open(pathname, [extension])

Opens a directory and returns a Dir object representing the files in the directory.

 for filename in Dir.open(path) do ... end
Arguments
pathname
The pathname of the directory.
extension (optional)
If given, only files with this extension will be returned.
Returns

the Dir object.

11.10.1.6. Dir.personal_config_path([filename])

Gets the personal configuration directory path, with filename if supplied.

Since: 1.11.3

Arguments
filename (optional)
A filename.
Returns

The full pathname for a file in the personal configuration directory.

11.10.1.7. Dir.global_config_path([filename])

Gets the global configuration directory path, with filename if supplied.

Since: 1.11.3

Arguments
filename (optional)
A filename
Returns

The full pathname for a file in wireshark’s configuration directory.

11.10.1.8. Dir.personal_plugins_path()

Gets the personal plugins directory path.

Since: 1.11.3

Returns

The pathname for the personal plugins directory.

11.10.1.9. Dir.global_plugins_path()

Gets the global plugins directory path.

Since: 1.11.3

Returns

The pathname for the global plugins directory.

11.10.1.10. dir:__call()

At every invocation will return one file (nil when done).

11.10.1.11. dir:close()

Closes the directory.