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.

copy

(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

delete

(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?

(dir? path)

Tests whether the path is a directory.

Tests whether the path is a directory.
sourceraw docstring

exists?

(exists? path)

Tests whether the path exists.

Tests whether the path exists.
sourceraw docstring

extension

(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?

(file? path)

Tests whether the path is a file.

Tests whether the path is a file.
sourceraw docstring

lines

(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?

(link? path)

Tests whether the path is a symbolic link.

Tests whether the path is a symbolic link.
sourceraw docstring

list

(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-dir

(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-dirs

(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-file

(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-parents

(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

move

(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

path

(path x & more)

Creates a Path using the segments provided.

Creates a Path using the segments provided.
sourceraw docstring

Pathishprotocol

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

read-bytes

(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-lines

(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-str

(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?

(same? x y)

Tests whether two paths point to the same file.

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

size

(size path)

Calculates the size of the file at the path.

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

temp-dir

(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-file

(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

walk

(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-bytes

(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-lines

(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-str

(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