Dir
The Dir module provides functions for working with directories in the file system.
Listing Contents
Dir.list
String -> List String
Lists all entries (files and subdirectories) in the specified directory.
entries = Dir.list "./src"
entries |> each (fn(name) => println name)
# => main.kit
# => utils.kit
# => lib/
Creating Directories
Dir.create
String -> Bool
Creates a directory at the specified path. Returns
true on success.
success = Dir.create "./output"
if success
println "Directory created!"
else
println "Failed to create directory"
Checking Existence
Dir.exists?
String -> Bool
Returns
true if the directory exists at the specified path.
if (Dir.exists? "./config")
println "Config directory found"
else
Dir.create "./config"
Deleting Directories
Dir.delete
String -> Bool
Deletes the directory at the specified path. Returns
true on success.
success = Dir.delete "./temp"
if success
println "Temp directory removed"