A Directory object, as well as associated functions.
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 members 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.
Boolean true on success, false if the directory already exists, nil on error.
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.
Boolean true if the directory exists, false if it’s a file, nil on error or not-exist.
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().
Boolean true on success, false if does not exist, nil on error.
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.
Boolean true on success, false if does not exist, nil on error.
Opens a directory and returns a Dir object representing the files in the directory.
-- Print the contents of a directory
for filename in Dir.open('/path/to/dir') do
print(filename)
end
The Dir object.
Gets the personal configuration directory path, with filename if supplied.
The full pathname for a file in the personal configuration directory.
Gets the global configuration directory path, with filename if supplied.
The full pathname for a file in Wireshark’s configuration directory.
-- Open a directory and print the name of the first file or subdirectory
local dir = Dir.open('/path/to/dir')
local first = dir()
print(tostring(file))
Closes the directory. Called automatically during garbage collection of a Dir object.