diff --git a/API.md b/API.md index d2db330..ae30763 100644 --- a/API.md +++ b/API.md @@ -28,7 +28,7 @@ - [`extension`](#babashka.fs/extension) - Returns the extension of path via [split-ext](#babashka.fs/split-ext). - [`file`](#babashka.fs/file) - Coerces path(s) into a File, combining multiple paths into one. - [`file-name`](#babashka.fs/file-name) - Returns the name of the file or directory for path via [File#getName](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#getName()). - - [`file-separator`](#babashka.fs/file-separator) - The system-dependent default path component separator character (as string). + - [`file-separator`](#babashka.fs/file-separator) - The system-dependent default path component separator character (as string) via [File/separator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#separator). - [`file-time->instant`](#babashka.fs/file-time->instant) - Converts ft [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html) to an [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html). - [`file-time->millis`](#babashka.fs/file-time->millis) - Converts ft [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html) to epoch milliseconds (long). - [`get-attribute`](#babashka.fs/get-attribute) - Returns value of attribute for path via [Files/getAttribute](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#getAttribute(java.nio.file.Path,java.lang.String,java.nio.file.LinkOption...)). @@ -49,8 +49,8 @@ - [`owner`](#babashka.fs/owner) - Returns the owner of path via [Files/getOwner](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...)). - [`parent`](#babashka.fs/parent) - Returns parent path of path via [Path#getParent](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Path.html#getParent()). - [`path`](#babashka.fs/path) - Coerces path(s) into a Path, combining multiple paths into one. - - [`path-separator`](#babashka.fs/path-separator) - The system-dependent path-separator character (as string). - - [`posix->str`](#babashka.fs/posix->str) - Converts a set of PosixFilePermission p to a string, like "rwx------". + - [`path-separator`](#babashka.fs/path-separator) - The system-dependent path-separator character (as string) via [File/pathSeparator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#pathSeparator). + - [`posix->str`](#babashka.fs/posix->str) - Converts a set of PosixFilePermission p to a string, like "rwx------" via [PosixFilePermissions/toString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#toString(java.util.Set)). - [`posix-file-permissions`](#babashka.fs/posix-file-permissions) - Returns a set of PosixFilePermission for path via [Files/getPosixFilePermissions](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#getPosixFilePermissions(java.nio.file.Path,java.nio.file.LinkOption...)). - [`read-all-bytes`](#babashka.fs/read-all-bytes) - Returns contents of file as byte array via [Files/readAllBytes](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#readAllBytes(java.nio.file.Path)). - [`read-all-lines`](#babashka.fs/read-all-lines) - Returns contents of file as a vector of lines via [Files/readAllLines](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#readAllLines(java.nio.file.Path,java.nio.charset.Charset)). @@ -72,7 +72,7 @@ - [`split-ext`](#babashka.fs/split-ext) - Splits path on extension. - [`split-paths`](#babashka.fs/split-paths) - Splits joined-paths string into a vector of paths by OS-specific [path-separator](#babashka.fs/path-separator). - [`starts-with?`](#babashka.fs/starts-with?) - Returns true if this-path starts with other-path via [Path#startsWith](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Path.html#startsWith(java.nio.file.Path)). - - [`str->posix`](#babashka.fs/str->posix) - Converts a string s to a set of PosixFilePermission. + - [`str->posix`](#babashka.fs/str->posix) - Converts string s to a set of PosixFilePermission via [PosixFilePermissions/fromString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#fromString(java.lang.String)). - [`strip-ext`](#babashka.fs/strip-ext) - Strips extension from path via [split-ext](#babashka.fs/split-ext). - [`sym-link?`](#babashka.fs/sym-link?) - Returns true if path is a symbolic link via [Files/isSymbolicLink](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#isSymbolicLink(java.nio.file.Path)). - [`temp-dir`](#babashka.fs/temp-dir) - Returns java.io.tmpdir property as path. @@ -469,7 +469,7 @@ See also: [`home`](#babashka.fs/home) Function. Returns the extension of `path` via [`split-ext`](#babashka.fs/split-ext). -

Source

+

Source

## `file` ``` clojure @@ -498,7 +498,7 @@ E.g. `(file-name "foo/bar/baz")` returns `"baz"`. -The system-dependent default path component separator character (as string). +The system-dependent default path component separator character (as string) via [File/separator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#separator).

Source

## `file-time->instant` @@ -681,7 +681,7 @@ Function. Similar to [`list-dir`](#babashka.fs/list-dir) but accepts multiple roots in `dirs` and returns the concatenated results. - `glob-or-accept` - a [`glob`](#babashka.fs/glob) string such as `"*.edn"` or a `(fn accept [^java.nio.file.Path p]) -> truthy` -

Source

+

Source

## `match` ``` clojure @@ -803,7 +803,7 @@ args as children relative to the parent. -The system-dependent path-separator character (as string). +The system-dependent path-separator character (as string) via [File/pathSeparator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#pathSeparator).

Source

## `posix->str` @@ -812,7 +812,7 @@ The system-dependent path-separator character (as string). ``` Function. -Converts a set of `PosixFilePermission` `p` to a string, like `"rwx------"`. +Converts a set of `PosixFilePermission` `p` to a string, like `"rwx------"` via [PosixFilePermissions/toString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#toString(java.util.Set)). See also: [`str->posix`](#babashka.fs/str->posix)

Source

@@ -995,7 +995,7 @@ Sets `attribute` for `path` to `value` via [Files/setAttribute](https://docs.ora Function. Sets creation `time` of `path`. -`time` can be `epoch milliseconds`, +`time` can be `epoch milliseconds` (long), [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html), or [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html). @@ -1015,7 +1015,7 @@ See also: [`creation-time`](#babashka.fs/creation-time) Function. Sets last modified `time` of `path`. -`time` can be `epoch milliseconds`, +`time` can be `epoch milliseconds` (long), [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html), or [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html). @@ -1060,7 +1060,7 @@ Examples: - `(fs/split-ext "foo.bar.baz")` => `["foo.bar" "baz"]` - `(fs/split-ext "foo.bar.baz" {:ext "bar.baz"})` => `["foo" "bar.baz"]` - `(fs/split-ext "foo.bar.baz" {:ext "png"})` => `["foo.bar.baz" nil]` -

Source

+

Source

## `split-paths` ``` clojure @@ -1069,8 +1069,7 @@ Examples: Function. Splits `joined-paths` string into a vector of paths by OS-specific [`path-separator`](#babashka.fs/path-separator). -On UNIX systems, the separator is `:`, on Microsoft Windows systems it is `;`. -

Source

+

Source

## `starts-with?` ``` clojure @@ -1089,7 +1088,7 @@ See also: [`ends-with?`](#babashka.fs/ends-with?) ``` Function. -Converts a string `s` to a set of `PosixFilePermission`. +Converts string `s` to a set of `PosixFilePermission` via [PosixFilePermissions/fromString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#fromString(java.lang.String)). `s` is a string like `"rwx------"`. @@ -1104,7 +1103,7 @@ See also: [`posix->str`](#babashka.fs/posix->str) Function. Strips extension from `path` via [`split-ext`](#babashka.fs/split-ext). -

Source

+

Source

## `sym-link?` ``` clojure @@ -1138,9 +1137,10 @@ a `NoSuchFileException` will be thrown. Callers can, if their use case requires implement their own retry loop. Options: -* `:time` - last modified time (epoch milliseconds, `Instant`, or `FileTime`), defaults to current time +* `:time` - last modified time (epoch milliseconds (long), [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html), +or [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html)), defaults to current time * [`:nofollow-links`](/README.md#nofollow-links) -

Source

+

Source

## `unixify` ``` clojure @@ -1163,7 +1163,7 @@ Unzips `zip-file` to `target-dir` (default `"."`). Options: * `:replace-existing` - `true` / `false`: overwrite existing files - * `:extract-fn` - function that decides if the current `ZipEntry` + * `:extract-fn` - function that decides if the current [ZipEntry](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/zip/ZipEntry.html) should be extracted. Extraction only occurs if a truthy value is returned (i.e. not nil/false). The function is only called for files (not directories) with a single map arg: * `:entry` - the current `ZipEntry` diff --git a/src/babashka/fs.cljc b/src/babashka/fs.cljc index 0b0772c..1b89c9b 100644 --- a/src/babashka/fs.cljc +++ b/src/babashka/fs.cljc @@ -314,11 +314,11 @@ (as-path path))) (def file-separator - "The system-dependent default path component separator character (as string)." + "The system-dependent default path component separator character (as string) via [File/separator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#separator)." File/separator) (def path-separator - "The system-dependent path-separator character (as string)." + "The system-dependent path-separator character (as string) via [File/pathSeparator](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#pathSeparator)." File/pathSeparator) (def ^:private win? @@ -486,14 +486,14 @@ (Files/copy (as-path source-file) dest copy-options))))) (defn posix->str - "Converts a set of `PosixFilePermission` `p` to a string, like `\"rwx------\"`. + "Converts a set of `PosixFilePermission` `p` to a string, like `\"rwx------\"` via [PosixFilePermissions/toString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#toString(java.util.Set)). See also: [[str->posix]]" [p] (PosixFilePermissions/toString p)) (defn str->posix - "Converts a string `s` to a set of `PosixFilePermission`. + "Converts string `s` to a set of `PosixFilePermission` via [PosixFilePermissions/fromString](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/PosixFilePermissions.html#fromString(java.lang.String)). `s` is a string like `\"rwx------\"`. @@ -1005,7 +1005,7 @@ (defn set-last-modified-time "Sets last modified `time` of `path`. - `time` can be `epoch milliseconds`, + `time` can be `epoch milliseconds` (long), [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html), or [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html). @@ -1028,7 +1028,7 @@ (defn set-creation-time "Sets creation `time` of `path`. - `time` can be `epoch milliseconds`, + `time` can be `epoch milliseconds` (long), [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html), or [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html). @@ -1051,7 +1051,8 @@ implement their own retry loop. Options: - * `:time` - last modified time (epoch milliseconds, `Instant`, or `FileTime`), defaults to current time + * `:time` - last modified time (epoch milliseconds (long), [Instant](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Instant.html), + or [FileTime](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/attribute/FileTime.html)), defaults to current time * [`:nofollow-links`](/README.md#nofollow-links)" ([path] (touch path nil)) @@ -1118,8 +1119,7 @@ (-> path split-ext last)) (defn split-paths - "Splits `joined-paths` string into a vector of paths by OS-specific [[path-separator]]. - On UNIX systems, the separator is `:`, on Microsoft Windows systems it is `;`." + "Splits `joined-paths` string into a vector of paths by OS-specific [[path-separator]]." [^String joined-paths] (mapv path (.split joined-paths path-separator))) @@ -1254,7 +1254,7 @@ Options: * `:replace-existing` - `true` / `false`: overwrite existing files - * `:extract-fn` - function that decides if the current `ZipEntry` + * `:extract-fn` - function that decides if the current [ZipEntry](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/zip/ZipEntry.html) should be extracted. Extraction only occurs if a truthy value is returned (i.e. not nil/false). The function is only called for files (not directories) with a single map arg: * `:entry` - the current `ZipEntry`