Liking cljdoc? Tell your friends :D

babashka.fs


absolute?clj

(absolute? f)

Returns true if f represents an absolute path.

Returns true if f represents an absolute path.
sourceraw docstring

absolutizeclj

(absolutize f)

Converts f into an absolute path via Path#toAbsolutePath.

Converts f into an absolute path via Path#toAbsolutePath.
sourceraw docstring

canonicalizeclj

(canonicalize f)
(canonicalize f {:keys [:nofollow-links]})

Returns the canonical path via java.io.File#getCanonicalPath. If :nofollow-links is set, then it will fall back on absolutize + normalize. This function can be used as an alternative to real-path which requires files to exist.

Returns the canonical path via
java.io.File#getCanonicalPath. If `:nofollow-links` is set, then it
will fall back on `absolutize` + `normalize.` This function can be used
as an alternative to `real-path` which requires files to exist.
sourceraw docstring

componentsclj

(components f)

Returns a seq of all components of f.

Returns a seq of all components of f.
sourceraw docstring

copyclj

(copy src dest)
(copy src dest {:keys [:replace-existing :copy-attributes :nofollow-links]})

Copies src file to dest dir or file. Options:

  • :replace-existing
  • :copy-attributes
  • :nofollow-links (used to determine to copy symbolic link itself or not).
Copies src file to dest dir or file.
Options:
* `:replace-existing`
* `:copy-attributes`
* `:nofollow-links` (used to determine to copy symbolic link itself or not).
sourceraw docstring

copy-treeclj

(copy-tree src dest)
(copy-tree src
           dest
           {:keys [:replace-existing :copy-attributes :nofollow-links]
            :as opts})

Copies entire file tree from src to dest. Creates dest if needed using create-dirs, passing it the :posix-file-permissions option. Supports same options as copy.

Copies entire file tree from src to dest. Creates dest if needed
using `create-dirs`, passing it the `:posix-file-permissions`
option. Supports same options as copy.
sourceraw docstring

create-dirclj

(create-dir path)
(create-dir path {:keys [:posix-file-permissions]})

Creates dir using Files#createDirectory. Does not create parents.

Creates dir using `Files#createDirectory`. Does not create parents.
sourceraw docstring

create-dirsclj

(create-dirs path)
(create-dirs path {:keys [:posix-file-permissions]})

Creates directories using Files#createDirectories. Also creates parents if needed.

Creates directories using `Files#createDirectories`. Also creates parents if needed.
sourceraw docstring

create-fileclj

(create-file path)
(create-file path {:keys [:posix-file-permissions]})

Creates empty file using Files#createFile.

Creates empty file using `Files#createFile`.
sourceraw docstring

(create-link path target)

Create a hard link from path to target.

Create a hard link from path to target.
sourceraw docstring

(create-sym-link path target)

Create a soft link from path to target.

Create a soft link from path to target.
sourceraw docstring

create-temp-dirclj

(create-temp-dir)
(create-temp-dir {:keys [:prefix :path :posix-file-permissions]})

Creates a temporary directory using Files#createDirectories.

(create-temp-dir): creates temp dir with random prefix. (create-temp-dir {:keys [:prefix :path :posix-file-permissions]}):

create temp dir in path with prefix. If prefix is not provided, a random one is generated. If path is not provided, the directory is created as if called with (create-temp-dir). The :posix-file-permissions option is a string like "rwx------".

Creates a temporary directory using Files#createDirectories.

`(create-temp-dir)`: creates temp dir with random prefix.
`(create-temp-dir {:keys [:prefix :path :posix-file-permissions]})`:

create temp dir in path with prefix. If prefix is not provided, a random one
is generated. If path is not provided, the directory is created as if called with `(create-temp-dir)`. The `:posix-file-permissions` option is a string like `"rwx------"`.
sourceraw docstring

create-temp-fileclj

(create-temp-file)
(create-temp-file {:keys [:path :prefix :suffix :posix-file-permissions]})

Creates an empty temporary file using Files#createTempFile.

  • (create-temp-file): creates temp file with random prefix and suffix.
  • (create-temp-dir {:keys [:prefix :suffix :path :posix-file-permissions]}): create temp file in path with prefix. If prefix and suffix are not provided, random ones are generated. The :posix-file-permissions option is a string like "rwx------".
Creates an empty temporary file using Files#createTempFile.

- `(create-temp-file)`: creates temp file with random prefix and suffix.
- `(create-temp-dir {:keys [:prefix :suffix :path :posix-file-permissions]})`: create
temp file in path with prefix. If prefix and suffix are not
provided, random ones are generated. The `:posix-file-permissions`
option is a string like `"rwx------"`.
sourceraw docstring

creation-timeclj

(creation-time f)
(creation-time f {:keys [nofollow-links] :as opts})

Returns creation time as FileTime.

Returns creation time as FileTime.
sourceraw docstring

cwdclj

(cwd)

Returns current working directory as path

Returns current working directory as path
sourceraw docstring

deleteclj

(delete f)

Deletes f. Returns nil if the delete was successful, throws otherwise. Does not follow symlinks.

Deletes f. Returns nil if the delete was successful,
throws otherwise. Does not follow symlinks.
sourceraw docstring

delete-if-existsclj

(delete-if-exists f)

Deletes f if it exists. Returns true if the delete was successful, false if f didn't exist. Does not follow symlinks.

Deletes f if it exists. Returns true if the delete was successful,
false if f didn't exist. Does not follow symlinks.
sourceraw docstring

delete-on-exitclj

(delete-on-exit f)

Requests delete on exit via File#deleteOnExit. Returns f.

Requests delete on exit via `File#deleteOnExit`. Returns f.
sourceraw docstring

delete-treeclj

(delete-tree root)

Deletes a file tree using walk-file-tree. Similar to rm -rf. Does not follow symlinks.

Deletes a file tree using `walk-file-tree`. Similar to `rm -rf`. Does not follow symlinks.
sourceraw docstring

directory?clj

(directory? f)
(directory? f {:keys [:nofollow-links]})

Returns true if f is a directory, using Files/isDirectory.

Returns true if f is a directory, using Files/isDirectory.
sourceraw docstring

ends-with?clj

(ends-with? this other)

Returns true if path this ends with path other.

Returns true if path this ends with path other.
sourceraw docstring

exec-pathsclj

(exec-paths)

Returns executable paths (using the PATH environment variable). Same as (split-paths (System/getenv "PATH")).

Returns executable paths (using the PATH environment variable). Same
as `(split-paths (System/getenv "PATH"))`.
sourceraw docstring

executable?clj

(executable? f)

Returns true if f is executable.

Returns true if f is executable.
sourceraw docstring

exists?clj

(exists? f)
(exists? f {:keys [:nofollow-links]})

Returns true if f exists.

Returns true if f exists.
sourceraw docstring

expand-homeclj

(expand-home f)

If path begins with a tilde (~), expand the tilde to the value of the user.home system property. If the path begins with a tilde immediately followed by some characters, they are assumed to be a username. This is expanded to the path to that user's home directory. This is (naively) assumed to be a directory with the same name as the user relative to the parent of the current value of user.home.

If `path` begins with a tilde (`~`), expand the tilde to the value
of the `user.home` system property. If the `path` begins with a
tilde immediately followed by some characters, they are assumed to
be a username. This is expanded to the path to that user's home
directory. This is (naively) assumed to be a directory with the same
name as the user relative to the parent of the current value of
`user.home`.
sourceraw docstring

extensionclj

(extension path)

Returns the extension of a file

Returns the extension of a file
sourceraw docstring

fileclj

(file f)
(file f & fs)

Coerces f into a File. Multiple-arg versions treat the first argument as parent and subsequent args as children relative to the parent.

Coerces f into a File. Multiple-arg versions treat the first argument
as parent and subsequent args as children relative to the parent.
sourceraw docstring

file-nameclj

(file-name x)

Returns the name of the file or directory. E.g. (file-name "foo/bar/baz") returns "baz".

Returns the name of the file or directory. E.g. (file-name "foo/bar/baz") returns "baz".
sourceraw docstring

file-separatorclj

source

file-time->instantclj

(file-time->instant ft)

Converts a java.nio.file.attribute.FileTime to a java.time.Instant.

Converts a java.nio.file.attribute.FileTime to a java.time.Instant.
sourceraw docstring

file-time->millisclj

(file-time->millis ft)

Converts a java.nio.file.attribute.FileTime to epoch millis (long).

Converts a java.nio.file.attribute.FileTime to epoch millis (long).
sourceraw docstring

get-attributeclj

(get-attribute path attribute)
(get-attribute path attribute {:keys [:nofollow-links]})
source

globclj

(glob root pattern)
(glob root pattern opts)

Given a file and glob pattern, returns matches as vector of files. Patterns containing ** or / will cause a recursive walk over path, unless overriden with :recursive. Glob interpretation is done using the rules described in https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String).

Options:

  • :hidden: match hidden files. Note: on Windows files starting with a dot are not hidden, unless their hidden attribute is set.
  • :follow-links: follow symlinks.
  • :recursive: force recursive search.

Examples: (fs/glob "." "**.clj")

Given a file and glob pattern, returns matches as vector of
files. Patterns containing `**` or `/` will cause a recursive walk over
path, unless overriden with :recursive. Glob interpretation is done
using the rules described in
https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String).

Options:

* `:hidden:` match hidden files. Note: on Windows files starting with
a dot are not hidden, unless their hidden attribute is set.
* `:follow-links:` follow symlinks.
* `:recursive:` force recursive search.

Examples:
`(fs/glob "." "**.clj")`
sourceraw docstring

hidden?clj

(hidden? f)

Returns true if f is hidden.

Returns true if f is hidden.
sourceraw docstring

homeclj

(home)
(home user)

With no arguments, returns the current value of the user.home system property. If a user is passed, returns that user's home directory as found in the parent of home with no args.

With no arguments, returns the current value of the `user.home`
system property. If a `user` is passed, returns that user's home
directory as found in the parent of home with no args.
sourceraw docstring

instant->file-timeclj

(instant->file-time instant)

Converts a java.time.Instant to a java.nio.file.attribute.FileTime.

Converts a java.time.Instant to a java.nio.file.attribute.FileTime.
sourceraw docstring

last-modified-timeclj

(last-modified-time f)
(last-modified-time f {:keys [nofollow-links] :as opts})

Returns last modified time as a java.nio.file.attribute.FileTime.

Returns last modified time as a java.nio.file.attribute.FileTime.
sourceraw docstring

list-dirclj

(list-dir dir)
(list-dir dir glob-or-accept)

Returns all paths in dir as vector. For descending into subdirectories use glob.

  • glob-or-accept - a glob string such as "*.edn" or a (fn accept [^java.nio.file.Path p]) -> truthy
Returns all paths in dir as vector. For descending into subdirectories use `glob.`
- `glob-or-accept` - a glob string such as "*.edn" or a (fn accept [^java.nio.file.Path p]) -> truthy
sourceraw docstring

list-dirsclj

(list-dirs dirs glob-or-accept)

Similar to list-dir but accepts multiple roots and returns the concatenated results.

  • glob-or-accept - a glob string such as "*.edn" or a (fn accept [^java.nio.file.Path p]) -> truthy
Similar to list-dir but accepts multiple roots and returns the concatenated results.
- `glob-or-accept` - a glob string such as "*.edn" or a (fn accept [^java.nio.file.Path p]) -> truthy
sourceraw docstring

matchclj

(match root pattern)
(match root pattern {:keys [hidden follow-links max-depth recursive]})

Given a file and match pattern, returns matches as vector of files. Pattern interpretation is done using the rules described in https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String).

Options:

  • :hidden: match hidden files - note: on Windows files starting with a dot are not hidden, unless their hidden attribute is set.
  • :follow-links: - follow symlinks
  • :recursive: - match recursively.
  • :max-depth: - max depth to descend into directory structure.

Examples: (fs/match "." "regex:.*\\.clj" {:recursive true})

Given a file and match pattern, returns matches as vector of
files. Pattern interpretation is done using the rules described in
https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String).

Options:

* `:hidden:` match hidden files - note: on Windows files starting with
a dot are not hidden, unless their hidden attribute is set.
* `:follow-links:` - follow symlinks
* `:recursive:` - match recursively.
* `:max-depth:` - max depth to descend into directory structure.

Examples:
`(fs/match "." "regex:.*\\.clj" {:recursive true})`
sourceraw docstring

millis->file-timeclj

(millis->file-time millis)

Converts epoch millis (long) to a java.nio.file.attribute.FileTime.

Converts epoch millis (long) to a java.nio.file.attribute.FileTime.
sourceraw docstring

modified-sinceclj

(modified-since anchor file-set)

Returns seq of regular files (non-directories, non-symlinks) from file-set that were modified since the anchor path. The anchor path can be a regular file or directory, in which case the recursive max last modified time stamp is used as the timestamp to compare with. The file-set may be a regular file, directory or collection of files (e.g. returned by glob). Directories are searched recursively.

Returns seq of regular files (non-directories, non-symlinks) from file-set that were modified since the anchor path.
The anchor path can be a regular file or directory, in which case
the recursive max last modified time stamp is used as the timestamp
to compare with.  The file-set may be a regular file, directory or
collection of files (e.g. returned by glob). Directories are
searched recursively.
sourceraw docstring

moveclj

(move source target)
(move source target {:keys [:replace-existing :atomic-move :nofollow-links]})

Move or rename a file to a target dir or file via Files/move.

Move or rename a file to a target dir or file via `Files/move`.
sourceraw docstring

normalizeclj

(normalize f)

Normalizes f via Path#normalize.

Normalizes f via Path#normalize.
sourceraw docstring

parentclj

(parent f)

Returns parent of f, is it exists.

Returns parent of f, is it exists.
sourceraw docstring

pathclj

(path f)
(path parent child)
(path parent child & more)

Coerces f into a Path. Multiple-arg versions treat the first argument as parent and subsequent args as children relative to the parent.

Coerces f into a Path. Multiple-arg versions treat the first argument as
parent and subsequent args as children relative to the parent.
sourceraw docstring

path-separatorclj

source

posix->strclj

(posix->str p)

Converts a set of PosixFilePermission to a string.

Converts a set of PosixFilePermission to a string.
sourceraw docstring

posix-file-permissionsclj

(posix-file-permissions f)
(posix-file-permissions f {:keys [:nofollow-links]})

Gets f's posix file permissions. Use posix->str to view as a string.

Gets f's posix file permissions. Use posix->str to view as a string.
sourceraw docstring

read-all-bytesclj

(read-all-bytes f)

Returns contents of file as byte array.

Returns contents of file as byte array.
sourceraw docstring

read-all-linesclj

(read-all-lines f)
(read-all-lines f {:keys [charset] :or {charset "utf-8"}})

Read all lines from a file.

Read all lines from a file.
sourceraw docstring

read-attributesclj

(read-attributes path attributes)
(read-attributes path attributes {:keys [:nofollow-links :key-fn] :as opts})

Same as read-attributes* but turns attributes into a map and keywordizes keys. Keywordizing can be changed by passing a :key-fn in the options map.

Same as `read-attributes*` but turns attributes into a map and keywordizes keys.
Keywordizing can be changed by passing a :key-fn in the options map.
sourceraw docstring

read-attributes*clj

(read-attributes* path attributes)
(read-attributes* path attributes {:keys [:nofollow-links]})

Reads attributes via Files/readAttributes.

Reads attributes via Files/readAttributes.
sourceraw docstring

readable?clj

(readable? f)

Returns true if f is readable

Returns true if f is readable
sourceraw docstring

real-pathclj

(real-path f)
(real-path f {:keys [:nofollow-links]})

Converts f into real path via Path#toRealPath.

Converts f into real path via Path#toRealPath.
sourceraw docstring

regular-file?clj

(regular-file? f)
(regular-file? f {:keys [:nofollow-links]})

Returns true if f is a regular file, using Files/isRegularFile.

Returns true if f is a regular file, using Files/isRegularFile.
sourceraw docstring

relative?clj

(relative? f)

Returns true if f represents a relative path.

Returns true if f represents a relative path.
sourceraw docstring

relativizeclj

(relativize this other)

Returns relative path by comparing this with other.

Returns relative path by comparing this with other.
sourceraw docstring

same-file?clj

(same-file? this other)

Returns true if this is the same file as other.

Returns true if this is the same file as other.
sourceraw docstring

set-attributeclj

(set-attribute path attribute value)
(set-attribute path attribute value {:keys [:nofollow-links]})
source

set-creation-timeclj

(set-creation-time f time)
(set-creation-time f time {:keys [nofollow-links] :as opts})

Sets creation time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime).

Sets creation time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime).
sourceraw docstring

set-last-modified-timeclj

(set-last-modified-time f time)
(set-last-modified-time f time {:keys [nofollow-links] :as opts})

Sets last modified time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime).

Sets last modified time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime).
sourceraw docstring

set-posix-file-permissionsclj

(set-posix-file-permissions f posix-file-permissions)

Sets posix file permissions on f. Accepts a string like "rwx------" or a set of PosixFilePermission.

Sets posix file permissions on f. Accepts a string like `"rwx------"` or a set of PosixFilePermission.
sourceraw docstring

sizeclj

(size f)

Returns the size of a file (in bytes).

Returns the size of a file (in bytes).
sourceraw docstring

split-extclj

(split-ext path)

Splits a path into a vec of [path-without-ext ext]. Works with strings, files, or paths.

Splits a path into a vec of [path-without-ext ext]. Works with strings, files, or paths.
sourceraw docstring

split-pathsclj

(split-paths joined-paths)

Splits a string joined by the OS-specific path-seperator into a vec of paths.

Splits a string joined by the OS-specific path-seperator into a vec of paths.
sourceraw docstring

starts-with?clj

(starts-with? this other)

Returns true if path this starts with path other.

Returns true if path this starts with path other.
sourceraw docstring

str->posixclj

(str->posix s)

Converts a string to a set of PosixFilePermission.

Converts a string to a set of PosixFilePermission.
sourceraw docstring

strip-extclj

(strip-ext path)
(strip-ext path {:keys [ext]})

Returns the path with the extension removed. If provided, a specific extension will be removed.

Returns the path with the extension removed. If provided, a specific extension will be removed.
sourceraw docstring

sym-link?clj

(sym-link? f)
source

temp-dirclj

(temp-dir)

Returns java.io.tmpdir property as path.

Returns `java.io.tmpdir` property as path.
sourceraw docstring

unzipclj

(unzip zip-file)
(unzip zip-file dest)
(unzip zip-file dest {:keys [replace-existing]})

zip-file: zip archive to unzip (required) dest: destination directory (defaults to ".") Options:

  • :replace-existing - true / false: overwrite existing files
zip-file: zip archive to unzip (required)
dest: destination directory (defaults to ".")
Options:
* `:replace-existing` - `true` / `false`: overwrite existing files
sourceraw docstring

walk-file-treeclj

(walk-file-tree f
                {:keys [:pre-visit-dir :post-visit-dir :visit-file
                        :visit-file-failed :follow-links :max-depth]})

Walks f using Files/walkFileTree. Visitor functions: :pre-visit-dir, :post-visit-dir, :visit-file, :visit-file-failed. All visitor functions default to (constantly :continue). Supported return values: :continue, :skip-subtree, :skip-siblings, :terminate. A different return value will throw.

Walks f using Files/walkFileTree. Visitor functions: :pre-visit-dir,
:post-visit-dir, :visit-file, :visit-file-failed. All visitor functions
default to (constantly :continue). Supported return
values: :continue, :skip-subtree, :skip-siblings, :terminate. A
different return value will throw.
sourceraw docstring

whichclj

(which program)
(which program opts)

Returns Path to first program found in (exec-paths), similar to the which Unix command.

On Windows, also searches for program with filename extensions specified in :win-exts opt. Default is ["com" "exe" "bat" "cmd"]. If program already includes an extension from :win-exts, it will be searched as-is first.

Returns Path to first `program` found in (`exec-paths`), similar to the which Unix command.

On Windows, also searches for `program` with filename extensions specified in `:win-exts` `opt`.
Default is `["com" "exe" "bat" "cmd"]`.
If `program` already includes an extension from `:win-exts`, it will be searched as-is first.
sourceraw docstring

which-allclj

(which-all program)
(which-all program opts)

Returns every Path to program found in (exec-paths). See which.

Returns every Path to `program` found in (`exec-paths`). See `which`.
sourceraw docstring

windows?clj

(windows?)

Returns true if OS is Windows.

Returns true if OS is Windows.
sourceraw docstring

with-temp-dircljmacro

(with-temp-dir [binding-name options] & body)

Evaluate body with binding-name bound to a temporary directory.

The directory is created by passing options to create-temp-dir, and will be removed with delete-tree on exit from the scope.

options is a map with the keys as for create-temp-dir.

Evaluate body with binding-name bound to a temporary directory.

The directory is created by passing `options` to `create-temp-dir`,
and will be removed with `delete-tree` on exit from the scope.

`options` is a map with the keys as for create-temp-dir.
sourceraw docstring

writable?clj

(writable? f)

Returns true if f is writable

Returns true if f is writable
sourceraw docstring

zipclj

(zip zip-file entries)
(zip zip-file entries _opts)

Zips entry or entries into zip-file. An entry may be a file or directory. Directories are included recursively and their names are preserved in the zip file. Currently only accepts relative entries.

Zips entry or entries into zip-file. An entry may be a file or
directory. Directories are included recursively and their names are
preserved in the zip file. Currently only accepts relative entries.
sourceraw docstring

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

× close