diff --git a/API.md b/API.md index f390c05..2b0ccd6 100644 --- a/API.md +++ b/API.md @@ -106,7 +106,7 @@ ``` Returns true if f represents an absolute path. -

Source

+

Source

## `absolutize` ``` clojure @@ -115,7 +115,7 @@ Returns true if f represents an absolute path. ``` Converts f into an absolute path via Path#toAbsolutePath. -

Source

+

Source

## `canonicalize` ``` clojure @@ -128,7 +128,7 @@ Returns the canonical path via java.io.File#getCanonicalPath. If `:nofollow-links` is set, then it will fall back on [`absolutize`](#babashka.fs/absolutize) + `normalize.` This function can be used as an alternative to [`real-path`](#babashka.fs/real-path) which requires files to exist. -

Source

+

Source

## `components` ``` clojure @@ -138,7 +138,7 @@ Returns the canonical path via Returns a seq of all components of f as paths, i.e. split on the file separator. -

Source

+

Source

## `copy` ``` clojure @@ -152,7 +152,7 @@ Copies src file to dest dir or file. * `:replace-existing` * `:copy-attributes` * `:nofollow-links` (used to determine to copy symbolic link itself or not). -

Source

+

Source

## `copy-tree` ``` clojure @@ -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 @@ -174,7 +174,7 @@ Copies entire file tree from src to dest. Creates dest if needed ``` Creates dir using `Files#createDirectory`. Does not create parents. -

Source

+

Source

## `create-dirs` ``` clojure @@ -185,7 +185,7 @@ Creates dir using `Files#createDirectory`. Does not create parents. Creates directories using `Files#createDirectories`. Also creates parents if needed. Doesn't throw an exception if the dirs exist already. Similar to `mkdir -p` -

Source

+

Source

## `create-file` ``` 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,16 +293,18 @@ 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 (delete-tree root) +(delete-tree root {:keys [force]}) ``` Deletes a file tree using [`walk-file-tree`](#babashka.fs/walk-file-tree). Similar to `rm -rf`. Does not follow symlinks. -

Source

+ `force` ensures read-only directories/files are deleted. Similar to `chmod -R +wx` + `rm -rf` +

Source

## `directory?` ``` clojure @@ -312,7 +314,7 @@ Deletes a file tree using [`walk-file-tree`](#babashka.fs/walk-file-tree). Simil ``` Returns true if f is a directory, using Files/isDirectory. -

Source

+

Source

## `ends-with?` ``` clojure @@ -321,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 @@ -331,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 @@ -340,7 +342,7 @@ Returns executable paths (using the PATH environment variable). Same ``` Returns true if f is executable. -

Source

+

Source

## `exists?` ``` clojure @@ -350,7 +352,7 @@ Returns true if f is executable. ``` Returns true if f exists. -

Source

+

Source

## `expand-home` ``` clojure @@ -365,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 @@ -374,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 @@ -385,7 +387,7 @@ Returns the extension of a file via [`split-ext`](#babashka.fs/split-ext). Coerces f into a File. Multiple-arg versions treat the first argument as parent and subsequent args as children relative to the parent. -

Source

+

Source

## `file-name` ``` clojure @@ -394,13 +396,13 @@ Coerces f into a File. Multiple-arg versions treat the first argument ``` Returns the name of the file or directory. E.g. (file-name "foo/bar/baz") returns "baz". -

Source

+

Source

## `file-separator` -

Source

+

Source

## `file-time->instant` ``` clojure @@ -409,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 @@ -418,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 @@ -426,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 @@ -450,7 +452,7 @@ Given a file and glob pattern, returns matches as vector of Examples: `(fs/glob "." "**.clj")` -

Source

+

Source

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

Source

+

Source

## `gzip` ``` clojure @@ -477,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 @@ -486,7 +488,7 @@ Gzips `source-file` and writes the output to `dir/out-file`. ``` Returns true if f is hidden. -

Source

+

Source

## `home` ``` clojure @@ -498,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 @@ -507,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 @@ -517,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 @@ -528,7 +530,7 @@ Returns last modified time as a java.nio.file.attribute.FileTime. 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 -

Source

+

Source

## `list-dirs` ``` clojure @@ -538,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 @@ -561,7 +563,7 @@ Given a file and match pattern, returns matches as vector of Examples: `(fs/match "." "regex:.*\\.clj" {:recursive true})` -

Source

+

Source

## `millis->file-time` ``` clojure @@ -570,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 @@ -584,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 @@ -594,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 @@ -603,7 +605,7 @@ Move or rename a file to a target dir or file via `Files/move`. ``` Normalizes f via Path#normalize. -

Source

+

Source

## `owner` ``` clojure @@ -614,7 +616,7 @@ Normalizes f via Path#normalize. Returns the owner of a file. Call `str` on it to get the owner name as a string. -

Source

+

Source

## `parent` ``` clojure @@ -623,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 @@ -635,13 +637,13 @@ Returns parent of f. Akin to `dirname` in bash. Coerces f into a Path. Multiple-arg versions treat the first argument as parent and subsequent args as children relative to the parent. -

Source

+

Source

## `path-separator` -

Source

+

Source

## `posix->str` ``` clojure @@ -650,7 +652,7 @@ Coerces f into a Path. Multiple-arg versions treat the first argument as ``` Converts a set of PosixFilePermission to a string. -

Source

+

Source

## `posix-file-permissions` ``` clojure @@ -660,7 +662,7 @@ Converts a set of PosixFilePermission to a string. ``` Gets f's posix file permissions. Use posix->str to view as a string. -

Source

+

Source

## `read-all-bytes` ``` clojure @@ -669,7 +671,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 @@ -679,7 +681,7 @@ Returns contents of file as byte array. ``` Read all lines from a file. -

Source

+

Source

## `read-attributes` ``` clojure @@ -690,7 +692,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 @@ -700,7 +702,7 @@ Same as [`read-attributes*`](#babashka.fs/read-attributes*) but turns attributes ``` Reads attributes via Files/readAttributes. -

Source

+

Source

## `readable?` ``` clojure @@ -709,7 +711,7 @@ Reads attributes via Files/readAttributes. ``` Returns true if f is readable -

Source

+

Source

## `real-path` ``` clojure @@ -719,7 +721,7 @@ Returns true if f is readable ``` Converts f into real path via Path#toRealPath. -

Source

+

Source

## `regular-file?` ``` clojure @@ -729,7 +731,7 @@ Converts f into real path via Path#toRealPath. ``` Returns true if f is a regular file, using Files/isRegularFile. -

Source

+

Source

## `relative?` ``` clojure @@ -738,7 +740,7 @@ Returns true if f is a regular file, using Files/isRegularFile. ``` Returns true if f represents a relative path. -

Source

+

Source

## `relativize` ``` clojure @@ -747,7 +749,7 @@ Returns true if f represents a relative path. ``` Returns relative path by comparing this with other. -

Source

+

Source

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

Source

+

Source

## `set-attribute` ``` clojure @@ -764,7 +766,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 @@ -774,7 +776,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 @@ -784,7 +786,7 @@ 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 @@ -793,7 +795,7 @@ Sets last modified time of f to time (millis, java.time.Instant or java.nio.file ``` Sets posix file permissions on f. Accepts a string like `"rwx------"` or a set of PosixFilePermission. -

Source

+

Source

## `size` ``` clojure @@ -802,7 +804,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 @@ -814,7 +816,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 @@ -824,7 +826,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 @@ -833,7 +835,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 @@ -842,7 +844,7 @@ Returns true if path this starts with path other. ``` Converts a string to a set of PosixFilePermission. -

Source

+

Source

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

Source

+

Source

## `sym-link?` ``` clojure @@ -861,7 +863,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 @@ -870,7 +872,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 @@ -879,7 +881,7 @@ Returns `java.io.tmpdir` property as path. ``` Returns path as string with Unix-style file separators (`/`). -

Source

+

Source

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

Source

+

Source

## `update-file` ``` clojure @@ -908,7 +910,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 @@ -921,7 +923,7 @@ Walks f using Files/walkFileTree. Visitor functions: :pre-visit-dir, default to (constantly :continue). Supported return values: :continue, :skip-subtree, :skip-siblings, :terminate. A different return value will throw. -

Source

+

Source

## `which` ``` clojure @@ -940,7 +942,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 @@ -950,7 +952,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 @@ -959,7 +961,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 @@ -974,7 +976,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 @@ -983,7 +985,7 @@ Evaluate body with binding-name bound to a temporary directory. ``` Returns true if f is writable -

Source

+

Source

## `write-bytes` ``` clojure @@ -1006,7 +1008,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 @@ -1026,7 +1028,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 @@ -1039,7 +1041,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 @@ -1052,7 +1054,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 @@ -1065,7 +1067,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 @@ -1078,7 +1080,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 @@ -1095,4 +1097,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

diff --git a/CHANGELOG.md b/CHANGELOG.md index 7777955..73721a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ For a list of breaking changes, check [here](#breaking-changes). Babashka [fs](https://github.com/babashka/fs): file system utility library for Clojure -## Unreleased +## v0.5.20 (2023-12-21) -- [#119](https://github.com/babashka/fs/issues/119): `fs/delete-tree`: add `:force` flag to delete read-only directories/files. Set the flag to true in `fs/with-temp-dir`. +- [#119](https://github.com/babashka/fs/issues/119): `fs/delete-tree`: add `:force` flag to delete read-only directories/files. Set the flag to true in `fs/with-temp-dir` ([@jlesquembre](https://github.com/jlesquembre)) - [#102](https://github.com/babashka/fs/issues/102): add `gzip` and `gunzip` functions - [#113](https://github.com/babashka/fs/issues/113): `fs/glob`: enable `:hidden` (when not already set) when `pattern` starts with dot ([@eval](https://github.com/eval)). - [#117](https://github.com/babashka/fs/issues/117): fix `fs/match` and `fs/glob` not finding files in root-folder ([@eval](https://github.com/eval)). diff --git a/project.clj b/project.clj index 55e4244..868748d 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject babashka/fs "0.4.19" +(defproject babashka/fs "0.5.20" :description "Babashka file system utilities." :url "https://github.com/babashka/fs" :scm {:name "git"