File I/O & Paths
Console I/O
display
Print a value without a trailing newline.
(display "no newline")
(display 42)println
Print a value followed by a newline.
(println "with newline")
(println 42)print
Alias for display. Print without a trailing newline.
(print "also no newline")newline
Print a newline character.
(newline)read-line
Read a line of input from stdin.
(define name (read-line))File Operations
file/read
Read the entire contents of a file as a string.
(file/read "data.txt") ; => "file contents..."file/write
Write a string to a file, overwriting any existing content.
(file/write "out.txt" "content")file/append
Append a string to a file.
(file/append "log.txt" "new line\n")file/read-lines
Read a file as a list of lines.
(file/read-lines "data.txt") ; => ("line 1" "line 2" "line 3")file/write-lines
Write a list of strings to a file, one per line.
(file/write-lines "out.txt" '("a" "b" "c"))file/delete
Delete a file.
(file/delete "tmp.txt")file/rename
Rename or move a file.
(file/rename "old.txt" "new.txt")file/copy
Copy a file.
(file/copy "src.txt" "dst.txt")File Predicates
file/exists?
Test if a file or directory exists.
(file/exists? "data.txt") ; => #t or #ffile/is-file?
Test if a path is a regular file.
(file/is-file? "data.txt") ; => #tfile/is-directory?
Test if a path is a directory.
(file/is-directory? "src/") ; => #tfile/is-symlink?
Test if a path is a symbolic link.
(file/is-symlink? "link") ; => #t or #fDirectory Operations
file/list
List entries in a directory.
(file/list "src/") ; => ("main.rs" "lib.rs" ...)file/mkdir
Create a directory.
(file/mkdir "new-dir")file/info
Get file metadata. Returns a map with :size, :modified, and other keys.
(file/info "data.txt") ; => {:size 1234 :modified 1707955200 ...}Path Manipulation
path/join
Join path components.
(path/join "src" "main.rs") ; => "src/main.rs"
(path/join "a" "b" "c.txt") ; => "a/b/c.txt"path/dirname
Return the directory portion of a path.
(path/dirname "/a/b/c.txt") ; => "/a/b"path/basename
Return the filename portion of a path.
(path/basename "/a/b/c.txt") ; => "c.txt"path/extension
Return the file extension (without the dot).
(path/extension "file.rs") ; => "rs"
(path/extension "Makefile") ; => ""path/absolute
Return the absolute path.
(path/absolute ".") ; => "/full/path/to/current/dir"