jolt.fs is a file-system utility library over java.io.File. Its API mirrors babashka.fs where the two overlap, so the mental model transfers directly if you know babashka. Functions accept a String or a File; path-valued results are Files (Jolt's path value — there is no java.nio.file.Path). A handful of operations that need Path-level access — symbolic links and creation time — are not available on this host and throw a clean ex-info.
(require '[jolt.fs :as fs])
(fs/exists? "deps.edn") ; => true
(fs/create-dirs "target/classes/jolt") ; => #object[File ...]
(fs/glob "src" "**.clj") ; => seq of File under src ending .clj
(fs/which "sh") ; => #object[File /bin/sh]
Coercion and nesting
filef— coerce aString/Fileto aFile. With several args, nests:(file a b c)isa/b/c.
Predicates
Each takes a path and returns a boolean.
exists?,directory?,regular-file?,absolute?,relative?readable?,writable?,executable?,hidden?sym-link?— not supported on this host; throwsex-info.
Path pieces
file-namef— final path segment as a string.parentf— parent as aFile;nilat a root or a bare name.extensionf— extension without the dot;nilwhen there is none.strip-extf— file name without its extension.absolutizef— absoluteFile(resolves against CWD, no symlink walk).canonicalizef— canonicalFile(resolves./..and symlinks).cwd[]— current working directory as aFile.relativizeroot other— path ofotherrelative toroot, as aFile. Throws whenotheris not nested underroot.(fs/extension "src/jolt/core.clj") ; => "clj" (fs/extension "Makefile") ; => nil (fs/relativize "/a" "/a/b/c") ; => #object[File "b/c"]
Reading the tree
list-dirdir— immediate children as a (possibly empty) seq ofFiles.walkroot— depth-first seq of every file and directory underroot,rootfirst.globroot pattern— files underrootwhose path relative torootmatches a glob.**crosses directory separators,*and?stay within a segment,{a,b}alternates. Matches against the/-separated relative path; returnsFiles.(fs/glob "src" "**.clj") ; every .clj under src, recursively (fs/glob "test" "*.{clj,ss}") ; top-level clj/ss files in test/
Creation and deletion
create-dirdir— one directory level; the parent must exist. Returns theFile, throws if it can't be created.create-dirsdir— a directory and any missing parents. Returns theFile.create-filef— an empty file. Returns theFile.create-temp-dir[{:keys [prefix] :or {prefix "jolt-"}}]— fresh directory under the system temp dir.create-temp-file[{:keys [prefix suffix] :or {prefix "jolt-" suffix ".tmp"}}]— fresh file under the system temp dir.deletef— a file or empty directory; throws when it doesn't exist.delete-if-existsf— delete when present;truewhen something was deleted.delete-treeroot— a file or directory recursively. A missing path is a no-op.
Copy and move
sizef— file size in bytes.copysrc dst [{:keys [replace-existing]}]— copy a regular file todst. Throws ifsrcis a directory (usecopy-tree) or ifdstexists without:replace-existing. Returnsdst.copy-treesrc dst [opts]— copy a directory tree recursively. Returnsdst.movesrc dst [{:keys [replace-existing]}]— move (rename)srctodst. Falls back to copy-then-delete for a regular file when rename fails (cross-device). Returnsdst.
Times
last-modified-timef— last-modified time as ajava.time.Instant.set-last-modified-timef inst— set the last-modified time from anInstant.creation-timef— not supported on this host; throwsex-info.
Lookup
whichnm— the first executable namednmonPATH, as aFile, elsenil.read-linkf— not supported on this host; throwsex-info.