Liking cljdoc? Tell your friends :D

org.ajoberstar.cljj.file

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.
raw docstring

copyclj

(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)
sourceraw docstring

deleteclj

(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)
sourceraw docstring

dir?clj

(dir? path)

Tests whether the path is a directory.

Tests whether the path is a directory.
sourceraw docstring

exists?clj

(exists? path)

Tests whether the path exists.

Tests whether the path exists.
sourceraw docstring

extensionclj

(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.
sourceraw docstring

file?clj

(file? path)

Tests whether the path is a file.

Tests whether the path is a file.
sourceraw docstring

linesclj

(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")
sourceraw docstring

link?clj

(link? path)

Tests whether the path is a symbolic link.

Tests whether the path is a symbolic link.
sourceraw docstring

listclj

(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))
sourceraw docstring

make-dirclj

(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.
sourceraw docstring

make-dirsclj

(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.
sourceraw docstring

make-fileclj

(make-file path)

Creates an empty file at the path.

Creates an empty file at the path.
sourceraw docstring

(make-link path target)

Creates a symbolic link from 'path' to 'target'.

Creates a symbolic link from 'path' to 'target'.
sourceraw docstring

make-parentsclj

(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.
sourceraw docstring

moveclj

(move path target & {:as opts})

Moves the file or directory from 'path' to 'target'.

Moves the file or directory from 'path' to 'target'.
sourceraw docstring

pathclj

(path x & more)

Creates a Path using the segments provided.

Creates a Path using the segments provided.
sourceraw docstring

Pathishcljprotocol

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-pathclj

(as-path x)
sourceraw docstring

read-bytesclj

(read-bytes path)

Reads all bytes from a file and returns the byte[].

Reads all bytes from a file and returns the byte[].
sourceraw docstring

read-linesclj

(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")
sourceraw docstring

(read-link path)

Reads the target of a symbolic link.

Reads the target of a symbolic link.
sourceraw docstring

read-strclj

(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")
sourceraw docstring

same?clj

(same? x y)

Tests whether two paths point to the same file.

Tests whether two paths point to the same file.
sourceraw docstring

sizeclj

(size path)

Calculates the size of the file at the path.

Calculates the size of the file at the path.
sourceraw docstring

temp-dirclj

(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.
sourceraw docstring

temp-fileclj

(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.
sourceraw docstring

walkclj

(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))
sourceraw docstring

write-bytesclj

(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)
sourceraw docstring

write-linesclj

(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")
sourceraw docstring

write-strclj

(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")
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close