A straightforward wrapper of common java.nio.file.* functionality. All functions use the Pathish protocol to turn their arguments into Paths.
A straightforward wrapper of common java.nio.file.* functionality. All functions use the Pathish protocol to turn their arguments into Paths.
(copy from to & {:as opts})
Copies a file or directory. Options include: :recurse true to copy all files underneath the directory (default false)
Copies a file or directory. Options include: :recurse true to copy all files underneath the directory (default false)
(delete path & {:as opts})
Deletes a file or directory. Will not fail if the path does not exist. Options include: :recurse true to copy all files underneath the directory (default false)
Deletes a file or directory. Will not fail if the path does not exist. Options include: :recurse true to copy all files underneath the directory (default false)
(dir? path)
Tests whether the path is a directory.
Tests whether the path is a directory.
(exists? path)
Tests whether the path exists.
Tests whether the path exists.
(extension path)
Gets the extension of the path, if any. Nil returned if there is no extension.
Gets the extension of the path, if any. Nil returned if there is no extension.
(file? path)
Tests whether the path is a file.
Tests whether the path is a file.
(lines path & {:as opts})
Lazily reads lines from a file and returns them in a Stream. Be sure to use this in a with-open or use reduce/transducers to close the file.
;; just read first line (with-open [lines (file/lines path)] (first (stream/stream-seq lines)))
;; just read first character of each line (into [] (map first) (file/lines path))
Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
Lazily reads lines from a file and returns them in a Stream. Be sure to use this in a with-open or use reduce/transducers to close the file. ;; just read first line (with-open [lines (file/lines path)] (first (stream/stream-seq lines))) ;; just read first character of each line (into [] (map first) (file/lines path)) Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
(link? path)
Tests whether the path is a symbolic link.
Tests whether the path is a symbolic link.
(list path)
Lists the immediate children of a directory. Be sure to use this in a with-open or use reduce/transducers to close the stream.
;; just read first child (with-open [children (file/list path)] (first (stream/stream-seq children)))
;; just read the name of each file (into [] (map .getFileName) (file/list path))
Lists the immediate children of a directory. Be sure to use this in a with-open or use reduce/transducers to close the stream. ;; just read first child (with-open [children (file/list path)] (first (stream/stream-seq children))) ;; just read the name of each file (into [] (map .getFileName) (file/list path))
(make-dir path)
Creates an empty directory at the path. Parents must exist already.
Creates an empty directory at the path. Parents must exist already.
(make-dirs path)
Creates an empty directory at the path, including any parent directories, if they don't already exist.
Creates an empty directory at the path, including any parent directories, if they don't already exist.
(make-file path)
Creates an empty file at the path.
Creates an empty file at the path.
(make-link path target)
Creates a symbolic link from 'path' to 'target'.
Creates a symbolic link from 'path' to 'target'.
(make-parents path)
Creates parent directories of the path, if they don't already exist.
Creates parent directories of the path, if they don't already exist.
(move path target & {:as opts})
Moves the file or directory from 'path' to 'target'.
Moves the file or directory from 'path' to 'target'.
(path x & more)
Creates a Path using the segments provided.
Creates a Path using the segments provided.
Implement this protocl if your type can be converted to a java.nio.file.Path object.
Implement this protocl if your type can be converted to a java.nio.file.Path object.
(as-path x)
(read-bytes path)
Reads all bytes from a file and returns the byte[].
Reads all bytes from a file and returns the byte[].
(read-lines path & {:as opts})
Reads all lines from a file and returns them as a List. Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
Reads all lines from a file and returns them as a List. Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
(read-link path)
Reads the target of a symbolic link.
Reads the target of a symbolic link.
(read-str path & {:as opts})
Reads all bytes from a file and returns as a String. Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
Reads all bytes from a file and returns as a String. Options include: :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
(same? x y)
Tests whether two paths point to the same file.
Tests whether two paths point to the same file.
(size path)
Calculates the size of the file at the path.
Calculates the size of the file at the path.
(temp-dir prefix)
(temp-dir dir prefix)
Creates a temporary dir. Uses java.io.tmpdir as the parent folder unless 'dir' is provided.
Creates a temporary dir. Uses java.io.tmpdir as the parent folder unless 'dir' is provided.
(temp-file prefix suffix)
(temp-file dir prefix suffix)
Creates a temporary file. Uses java.io.tmpdir as the parent folder unless 'dir' is provided.
Creates a temporary file. Uses java.io.tmpdir as the parent folder unless 'dir' is provided.
(walk path)
(walk path max-depth)
Walks the file tree (depth-first) below a directory, returning a Stream. The first element will always be the given path. Be sure to use this in a with-open or use reduce/transducers to close the stream.
;; just read first descendant (with-open [children (file/walk path)] (first (stream/stream-seq children)))
;; just read the name of each file (into [] (map .getFileName) (file/walk path))
Walks the file tree (depth-first) below a directory, returning a Stream. The first element will always be the given path. Be sure to use this in a with-open or use reduce/transducers to close the stream. ;; just read first descendant (with-open [children (file/walk path)] (first (stream/stream-seq children))) ;; just read the name of each file (into [] (map .getFileName) (file/walk path))
(write-bytes path bytes & {:as opts})
Writes all bytes to a file (truncating any existing content). Options include: :append true to open file in append mode (default false, i.e. truncate)
Writes all bytes to a file (truncating any existing content). Options include: :append true to open file in append mode (default false, i.e. truncate)
(write-lines path lines & {:as opts})
Writes all lines to a file. Options include: :append true to open file in append mode (default false, i.e. truncate) :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
Writes all lines to a file. Options include: :append true to open file in append mode (default false, i.e. truncate) :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
(write-str path content & {:as opts})
Writes a String's bytes (as UTF-8) to to a file. Options include: :append true to open file in append mode (default false, i.e. truncate) :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
Writes a String's bytes (as UTF-8) to to a file. Options include: :append true to open file in append mode (default false, i.e. truncate) :encoding string name of charset (as supported by Charset/forName) (default "UTF-8")
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close