diff --git a/API.md b/API.md index 2b0ccd6..968b5d6 100644 --- a/API.md +++ b/API.md @@ -51,7 +51,7 @@ - [`path`](#babashka.fs/path) - Coerces f into a Path. - [`path-separator`](#babashka.fs/path-separator) - [`posix->str`](#babashka.fs/posix->str) - Converts a set of PosixFilePermission to a string. - - [`posix-file-permissions`](#babashka.fs/posix-file-permissions) - Gets f's posix file permissions. + - [`posix-file-permissions`](#babashka.fs/posix-file-permissions) - [`read-all-bytes`](#babashka.fs/read-all-bytes) - Returns contents of file as byte array. - [`read-all-lines`](#babashka.fs/read-all-lines) - Read all lines from a file. - [`read-attributes`](#babashka.fs/read-attributes) - Same as read-attributes* but turns attributes into a map and keywordizes keys. @@ -65,7 +65,7 @@ - [`set-attribute`](#babashka.fs/set-attribute) - [`set-creation-time`](#babashka.fs/set-creation-time) - Sets creation time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime). - [`set-last-modified-time`](#babashka.fs/set-last-modified-time) - Sets last modified time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime). - - [`set-posix-file-permissions`](#babashka.fs/set-posix-file-permissions) - Sets posix file permissions on f. + - [`set-posix-file-permissions`](#babashka.fs/set-posix-file-permissions) - [`size`](#babashka.fs/size) - Returns the size of a file (in bytes). - [`split-ext`](#babashka.fs/split-ext) - Splits path on extension If provided, a specific extension ext, the extension (without dot), will be used for splitting. - [`split-paths`](#babashka.fs/split-paths) - Splits a path list given as a string joined by the OS-specific path-separator into a vec of paths. @@ -164,7 +164,7 @@ Copies src file to dest dir or file. Copies entire file tree from src to dest. Creates dest if needed using [`create-dirs`](#babashka.fs/create-dirs), passing it the `:posix-file-permissions` option. Supports same options as copy. -

Source

+

Source

## `create-dir` ``` clojure @@ -195,7 +195,7 @@ Creates directories using `Files#createDirectories`. Also creates parents if nee ``` Creates empty file using `Files#createFile`. -

Source

+

Source

## `create-link` ``` clojure @@ -204,7 +204,7 @@ Creates empty file using `Files#createFile`. ``` Create a hard link from path to target. -

Source

+

Source

## `create-sym-link` ``` clojure @@ -213,7 +213,7 @@ Create a hard link from path to target. ``` Create a soft link from path to target. -

Source

+

Source

## `create-temp-dir` ``` clojure @@ -229,7 +229,7 @@ Creates a temporary directory using Files#createDirectories. create temp dir in dir 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------"`. -

Source

+

Source

## `create-temp-file` ``` clojure @@ -245,7 +245,7 @@ Creates an empty temporary file using Files#createTempFile. 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------"`. -

Source

+

Source

## `creation-time` ``` clojure @@ -255,7 +255,7 @@ Creates an empty temporary file using Files#createTempFile. ``` Returns creation time as FileTime. -

Source

+

Source

## `cwd` ``` clojure @@ -264,7 +264,7 @@ Returns creation time as FileTime. ``` Returns current working directory as path -

Source

+

Source

## `delete` ``` clojure @@ -274,7 +274,7 @@ Returns current working directory as path Deletes f. Returns nil if the delete was successful, throws otherwise. Does not follow symlinks. -

Source

+

Source

## `delete-if-exists` ``` clojure @@ -284,7 +284,7 @@ Deletes f. Returns nil if the delete was successful, Deletes f if it exists. Returns true if the delete was successful, false if f didn't exist. Does not follow symlinks. -

Source

+

Source

## `delete-on-exit` ``` clojure @@ -293,7 +293,7 @@ Deletes f if it exists. Returns true if the delete was successful, ``` Requests delete on exit via `File#deleteOnExit`. Returns f. -

Source

+

Source

## `delete-tree` ``` clojure @@ -304,7 +304,7 @@ Requests delete on exit via `File#deleteOnExit`. Returns f. Deletes a file tree using [`walk-file-tree`](#babashka.fs/walk-file-tree). Similar to `rm -rf`. Does not follow symlinks. `force` ensures read-only directories/files are deleted. Similar to `chmod -R +wx` + `rm -rf` -

Source

+

Source

## `directory?` ``` clojure @@ -323,7 +323,7 @@ Returns true if f is a directory, using Files/isDirectory. ``` Returns true if path this ends with path other. -

Source

+

Source

## `exec-paths` ``` clojure @@ -333,7 +333,7 @@ Returns true if path this ends with path other. Returns executable paths (using the PATH environment variable). Same as `(split-paths (System/getenv "PATH"))`. -

Source

+

Source

## `executable?` ``` clojure @@ -367,7 +367,7 @@ If [[`path`](#babashka.fs/path)](#babashka.fs/path) begins with a tilde (`~`), e 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`. -

Source

+

Source

## `extension` ``` clojure @@ -376,7 +376,7 @@ If [[`path`](#babashka.fs/path)](#babashka.fs/path) begins with a tilde (`~`), e ``` Returns the extension of a file via [`split-ext`](#babashka.fs/split-ext). -

Source

+

Source

## `file` ``` clojure @@ -411,7 +411,7 @@ Returns the name of the file or directory. E.g. (file-name "foo/bar/baz") return ``` Converts a java.nio.file.attribute.FileTime to a java.time.Instant. -

Source

+

Source

## `file-time->millis` ``` clojure @@ -420,7 +420,7 @@ Converts a java.nio.file.attribute.FileTime to a java.time.Instant. ``` Converts a java.nio.file.attribute.FileTime to epoch millis (long). -

Source

+

Source

## `get-attribute` ``` clojure @@ -428,7 +428,7 @@ Converts a java.nio.file.attribute.FileTime to epoch millis (long). (get-attribute path attribute) (get-attribute path attribute {:keys [:nofollow-links]}) ``` -

Source

+

Source

## `glob` ``` clojure @@ -466,7 +466,7 @@ Extracts `gz-file` to `dest` directory (default `"."`). Options: * `:replace-existing` - `true` / `false`: overwrite existing files -

Source

+

Source

## `gzip` ``` clojure @@ -479,7 +479,7 @@ Gzips `source-file` and writes the output to `dir/out-file`. If `out-file` is not provided, the `source-file` name with `.gz` appended is used. If `dir` is not provided, the current directory is used. Returns the created gzip file. -

Source

+

Source

## `hidden?` ``` clojure @@ -500,7 +500,7 @@ Returns true if f is hidden. 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. -

Source

+

Source

## `instant->file-time` ``` clojure @@ -509,7 +509,7 @@ With no arguments, returns the current value of the `user.home` ``` Converts a java.time.Instant to a java.nio.file.attribute.FileTime. -

Source

+

Source

## `last-modified-time` ``` clojure @@ -519,7 +519,7 @@ Converts a java.time.Instant to a java.nio.file.attribute.FileTime. ``` Returns last modified time as a java.nio.file.attribute.FileTime. -

Source

+

Source

## `list-dir` ``` clojure @@ -540,7 +540,7 @@ Returns all paths in dir as vector. For descending into subdirectories use `glob 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 -

Source

+

Source

## `match` ``` clojure @@ -572,7 +572,7 @@ Given a file and match pattern, returns matches as vector of ``` Converts epoch millis (long) to a java.nio.file.attribute.FileTime. -

Source

+

Source

## `modified-since` ``` clojure @@ -586,7 +586,7 @@ Returns seq of regular files (non-directories, non-symlinks) from file-set that 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. -

Source

+

Source

## `move` ``` clojure @@ -596,7 +596,7 @@ Returns seq of regular files (non-directories, non-symlinks) from file-set that ``` Move or rename a file to a target dir or file via `Files/move`. -

Source

+

Source

## `normalize` ``` clojure @@ -625,7 +625,7 @@ Returns the owner of a file. Call `str` on it to get the owner name ``` Returns parent of f. Akin to `dirname` in bash. -

Source

+

Source

## `path` ``` clojure @@ -655,14 +655,10 @@ Converts a set of PosixFilePermission to a string.

Source

## `posix-file-permissions` -``` clojure -(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. -

Source

+ +

Source

## `read-all-bytes` ``` clojure @@ -671,7 +667,7 @@ Gets f's posix file permissions. Use posix->str to view as a string. ``` Returns contents of file as byte array. -

Source

+

Source

## `read-all-lines` ``` clojure @@ -681,7 +677,7 @@ Returns contents of file as byte array. ``` Read all lines from a file. -

Source

+

Source

## `read-attributes` ``` clojure @@ -692,7 +688,7 @@ Read all lines from a file. Same as [`read-attributes*`](#babashka.fs/read-attributes*) but turns attributes into a map and keywordizes keys. Keywordizing can be changed by passing a :key-fn in the options map. -

Source

+

Source

## `read-attributes*` ``` clojure @@ -702,7 +698,7 @@ Same as [`read-attributes*`](#babashka.fs/read-attributes*) but turns attributes ``` Reads attributes via Files/readAttributes. -

Source

+

Source

## `readable?` ``` clojure @@ -758,7 +754,7 @@ Returns relative path by comparing this with other. ``` Returns true if this is the same file as other. -

Source

+

Source

## `set-attribute` ``` clojure @@ -766,7 +762,7 @@ Returns true if this is the same file as other. (set-attribute path attribute value) (set-attribute path attribute value {:keys [:nofollow-links]}) ``` -

Source

+

Source

## `set-creation-time` ``` clojure @@ -776,7 +772,7 @@ Returns true if this is the same file as other. ``` Sets creation time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime). -

Source

+

Source

## `set-last-modified-time` ``` clojure @@ -786,16 +782,13 @@ Sets creation time of f to time (millis, java.time.Instant or java.nio.file.attr ``` Sets last modified time of f to time (millis, java.time.Instant or java.nio.file.attribute.FileTime). -

Source

+

Source

## `set-posix-file-permissions` -``` clojure -(set-posix-file-permissions f posix-file-permissions) -``` -Sets posix file permissions on f. Accepts a string like `"rwx------"` or a set of PosixFilePermission. -

Source

+ +

Source

## `size` ``` clojure @@ -804,7 +797,7 @@ Sets posix file permissions on f. Accepts a string like `"rwx------"` or a set o ``` Returns the size of a file (in bytes). -

Source

+

Source

## `split-ext` ``` clojure @@ -816,7 +809,7 @@ Returns the size of a file (in bytes). Splits path on extension If provided, a specific extension `ext`, the extension (without dot), will be used for splitting. Directories are not processed. -

Source

+

Source

## `split-paths` ``` clojure @@ -826,7 +819,7 @@ Splits path on extension If provided, a specific extension `ext`, the Splits a path list given as a string joined by the OS-specific path-separator into a vec of paths. On UNIX systems, the separator is ':', on Microsoft Windows systems it is ';'. -

Source

+

Source

## `starts-with?` ``` clojure @@ -835,7 +828,7 @@ Splits a path list given as a string joined by the OS-specific path-separator in ``` Returns true if path this starts with path other. -

Source

+

Source

## `str->posix` ``` clojure @@ -854,7 +847,7 @@ Converts a string to a set of PosixFilePermission. ``` Strips extension via [`split-ext`](#babashka.fs/split-ext). -

Source

+

Source

## `sym-link?` ``` clojure @@ -863,7 +856,7 @@ Strips extension via [`split-ext`](#babashka.fs/split-ext). ``` Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`. -

Source

+

Source

## `temp-dir` ``` clojure @@ -872,7 +865,7 @@ Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`. ``` Returns `java.io.tmpdir` property as path. -

Source

+

Source

## `unixify` ``` clojure @@ -881,7 +874,7 @@ Returns `java.io.tmpdir` property as path. ``` Returns path as string with Unix-style file separators (`/`). -

Source

+

Source

## `unzip` ``` clojure @@ -895,7 +888,7 @@ Unzips `zip-file` to `dest` directory (default `"."`). Options: * `:replace-existing` - `true` / `false`: overwrite existing files -

Source

+

Source

## `update-file` ``` clojure @@ -910,7 +903,7 @@ Updates the contents of text file [`path`](#babashka.fs/path) using `f` applied Options: * `:charset` - charset of file, default to "utf-8" -

Source

+

Source

## `walk-file-tree` ``` clojure @@ -942,7 +935,7 @@ Returns Path to first executable `program` found in `:paths` `opt`, similar to t When `program` is a relative or absolute path, `:paths` is not consulted. On Windows, the `:win-exts` variants are still searched. On other OSes, the path for `program` will be returned if executable, else nil. -

Source

+

Source

## `which-all` ``` clojure @@ -952,7 +945,7 @@ Returns Path to first executable `program` found in `:paths` `opt`, similar to t ``` Returns every Path to `program` found in ([`exec-paths`](#babashka.fs/exec-paths)). See [`which`](#babashka.fs/which). -

Source

+

Source

## `windows?` ``` clojure @@ -961,7 +954,7 @@ Returns every Path to `program` found in ([`exec-paths`](#babashka.fs/exec-paths ``` Returns true if OS is Windows. -

Source

+

Source

## `with-temp-dir` ``` clojure @@ -976,7 +969,7 @@ Evaluate body with binding-name bound to a temporary directory. and will be removed with [`delete-tree`](#babashka.fs/delete-tree) on exit from the scope. `options` is a map with the keys as for create-temp-dir. -

Source

+

Source

## `writable?` ``` clojure @@ -1008,7 +1001,7 @@ Writes `bytes` to [`path`](#babashka.fs/path) via `java.nio.file.Files/write`. (fs/write-bytes f (.getBytes (String. "foo"))) ;; overwrites + truncates or creates new file (fs/write-bytes f (.getBytes (String. "foo")) {:append true}) ``` -

Source

+

Source

## `write-lines` ``` clojure @@ -1028,7 +1021,7 @@ Writes `lines`, a seqable of strings to [`path`](#babashka.fs/path) via `java.ni * `:write` (default `true`) * `:append` (default `false`) * or any `java.nio.file.StandardOption`. -

Source

+

Source

## `xdg-cache-home` ``` clojure @@ -1041,7 +1034,7 @@ Path representing the base directory relative to which user-specific non-essenti Returns path based on the value of env-var `XDG_CACHE_HOME` (if set and representing an absolute path), else `(fs/path (fs/home) ".cache")`. When provided, appends `app` to the path. -

Source

+

Source

## `xdg-config-home` ``` clojure @@ -1054,7 +1047,7 @@ Path representing the base directory relative to which user-specific configurati Returns path based on the value of env-var `XDG_CONFIG_HOME` (if set and representing an absolute path), else `(fs/path (fs/home) ".config")`. When provided, appends `app` to the path. -

Source

+

Source

## `xdg-data-home` ``` clojure @@ -1067,7 +1060,7 @@ Path representing the base directory relative to which user-specific data files Returns path based on the value of env-var `XDG_DATA_HOME` (if set and representing an absolute path), else `(fs/path (fs/home) ".local" "share")`. When provided, appends `app` to the path. -

Source

+

Source

## `xdg-state-home` ``` clojure @@ -1080,7 +1073,7 @@ Path representing the base directory relative to which user-specific state files Returns path based on the value of env-var `XDG_STATE_HOME` (if set and representing an absolute path), else `(fs/path (fs/home) ".local" "state")`. When provided, appends `app` to the path. -

Source

+

Source

## `zip` ``` clojure @@ -1097,4 +1090,4 @@ Zips entry or entries into zip-file. An entry may be a file or * `:root`: directory which will be elided in zip. E.g.: `(fs/zip ["src"] {:root "src"})` * `:path-fn`: a single-arg function from file system path to zip entry path. -

Source

+

Source