diff --git a/API.md b/API.md index 2f16b8d..6a21b87 100644 --- a/API.md +++ b/API.md @@ -107,7 +107,7 @@ ``` Returns true if f represents an absolute path. -
+ ## `absolutize` ``` clojure @@ -116,7 +116,7 @@ Returns true if f represents an absolute path. ``` Converts f into an absolute path via Path#toAbsolutePath. - + ## `canonicalize` ``` clojure @@ -129,7 +129,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. - + ## `components` ``` clojure @@ -139,7 +139,7 @@ Returns the canonical path via Returns a seq of all components of f as paths, i.e. split on the file separator. - + ## `copy` ``` clojure @@ -153,7 +153,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). - + ## `copy-tree` ``` clojure @@ -165,7 +165,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. - + ## `create-dir` ``` clojure @@ -175,7 +175,7 @@ Copies entire file tree from src to dest. Creates dest if needed ``` Creates dir using `Files#createDirectory`. Does not create parents. - + ## `create-dirs` ``` clojure @@ -186,7 +186,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` - + ## `create-file` ``` clojure @@ -199,7 +199,7 @@ Creates empty file using `Files#createFile`. File permissions can be specified with an `:posix-file-permissions` option. String format for posix file permissions is described in the [`str->posix`](#babashka.fs/str->posix) docstring. - + ## `create-link` ``` clojure @@ -208,7 +208,7 @@ Creates empty file using `Files#createFile`. ``` Create a hard link from path to target. - + ## `create-sym-link` ``` clojure @@ -217,7 +217,7 @@ Create a hard link from path to target. ``` Create a soft link from path to target. - + ## `create-temp-dir` ``` clojure @@ -235,7 +235,7 @@ Creates a temporary directory using Files#createDirectories. is generated. If path is not provided, the directory is created as if called with `(create-temp-dir)`. File permissions can be specified with an `:posix-file-permissions` option. String format for posix file permissions is described in the [`str->posix`](#babashka.fs/str->posix) docstring. - + ## `create-temp-file` ``` clojure @@ -253,7 +253,7 @@ Creates an empty temporary file using Files#createTempFile. random ones are generated. File permissions can be specified with an `:posix-file-permissions` option. String format for posix file permissions is described in the [`str->posix`](#babashka.fs/str->posix) docstring. - + ## `creation-time` ``` clojure @@ -263,7 +263,7 @@ Creates an empty temporary file using Files#createTempFile. ``` Returns creation time as FileTime. - + ## `cwd` ``` clojure @@ -272,7 +272,7 @@ Returns creation time as FileTime. ``` Returns current working directory as path - + ## `delete` ``` clojure @@ -282,7 +282,7 @@ Returns current working directory as path Deletes f. Returns nil if the delete was successful, throws otherwise. Does not follow symlinks. - + ## `delete-if-exists` ``` clojure @@ -292,7 +292,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. - + ## `delete-on-exit` ``` clojure @@ -301,7 +301,7 @@ Deletes f if it exists. Returns true if the delete was successful, ``` Requests delete on exit via `File#deleteOnExit`. Returns f. - + ## `delete-tree` ``` clojure @@ -312,7 +312,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` - + ## `directory?` ``` clojure @@ -322,7 +322,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. - + ## `ends-with?` ``` clojure @@ -331,7 +331,7 @@ Returns true if f is a directory, using Files/isDirectory. ``` Returns true if path this ends with path other. - + ## `exec-paths` ``` clojure @@ -341,7 +341,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"))`. - + ## `executable?` ``` clojure @@ -350,7 +350,7 @@ Returns executable paths (using the PATH environment variable). Same ``` Returns true if f is executable. - + ## `exists?` ``` clojure @@ -360,7 +360,7 @@ Returns true if f is executable. ``` Returns true if f exists. - + ## `expand-home` ``` clojure @@ -375,7 +375,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`. - + ## `extension` ``` clojure @@ -384,7 +384,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). - + ## `file` ``` clojure @@ -395,7 +395,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. - + ## `file-name` ``` clojure @@ -404,13 +404,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". - + ## `file-separator` - + ## `file-time->instant` ``` clojure @@ -419,7 +419,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. - + ## `file-time->millis` ``` clojure @@ -428,7 +428,7 @@ Converts a java.nio.file.attribute.FileTime to a java.time.Instant. ``` Converts a java.nio.file.attribute.FileTime to epoch millis (long). - + ## `get-attribute` ``` clojure @@ -436,7 +436,7 @@ Converts a java.nio.file.attribute.FileTime to epoch millis (long). (get-attribute path attribute) (get-attribute path attribute {:keys [:nofollow-links]}) ``` - + ## `glob` ``` clojure @@ -461,7 +461,7 @@ Given a file and glob pattern, returns matches as vector of Examples: `(fs/glob "." "**.clj")` - + ## `gunzip` ``` clojure @@ -475,7 +475,7 @@ Extracts `gz-file` to `dest` directory (default `"."`). Options: * `:replace-existing` - `true` / `false`: overwrite existing files - + ## `gzip` ``` clojure @@ -488,7 +488,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. - + ## `hidden?` ``` clojure @@ -497,7 +497,7 @@ Gzips `source-file` and writes the output to `dir/out-file`. ``` Returns true if f is hidden. - + ## `home` ``` clojure @@ -509,7 +509,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. - + ## `instant->file-time` ``` clojure @@ -518,7 +518,7 @@ With no arguments, returns the current value of the `user.home` ``` Converts a java.time.Instant to a java.nio.file.attribute.FileTime. - + ## `last-modified-time` ``` clojure @@ -528,7 +528,7 @@ Converts a java.time.Instant to a java.nio.file.attribute.FileTime. ``` Returns last modified time as a java.nio.file.attribute.FileTime. - + ## `list-dir` ``` clojure @@ -539,7 +539,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 - + ## `list-dirs` ``` clojure @@ -549,7 +549,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 - + ## `match` ``` clojure @@ -572,7 +572,7 @@ Given a file and match pattern, returns matches as vector of Examples: `(fs/match "." "regex:.*\\.clj" {:recursive true})` - + ## `millis->file-time` ``` clojure @@ -581,7 +581,7 @@ Given a file and match pattern, returns matches as vector of ``` Converts epoch millis (long) to a java.nio.file.attribute.FileTime. - + ## `modified-since` ``` clojure @@ -595,7 +595,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. - + ## `move` ``` clojure @@ -605,7 +605,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`. - + ## `normalize` ``` clojure @@ -614,7 +614,7 @@ Move or rename a file to a target dir or file via `Files/move`. ``` Normalizes f via Path#normalize. - + ## `owner` ``` clojure @@ -625,7 +625,7 @@ Normalizes f via Path#normalize. Returns the owner of a file. Call `str` on it to get the owner name as a string. - + ## `parent` ``` clojure @@ -634,7 +634,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. - + ## `path` ``` clojure @@ -646,13 +646,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. - + ## `path-separator` - + ## `posix->str` ``` clojure @@ -661,13 +661,13 @@ Coerces f into a Path. Multiple-arg versions treat the first argument as ``` Converts a set of PosixFilePermission to a string. - + ## `posix-file-permissions` - + ## `read-all-bytes` ``` clojure @@ -676,7 +676,7 @@ Converts a set of PosixFilePermission to a string. ``` Returns contents of file as byte array. - + ## `read-all-lines` ``` clojure @@ -686,7 +686,7 @@ Returns contents of file as byte array. ``` Read all lines from a file. - + ## `read-attributes` ``` clojure @@ -697,7 +697,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. - + ## `read-attributes*` ``` clojure @@ -707,7 +707,7 @@ Same as [`read-attributes*`](#babashka.fs/read-attributes*) but turns attributes ``` Reads attributes via Files/readAttributes. - + ## `read-link` ``` clojure @@ -716,7 +716,7 @@ Reads attributes via Files/readAttributes. ``` Reads the target of a symbolic link. The target need not exist. - + ## `readable?` ``` clojure @@ -725,7 +725,7 @@ Reads the target of a symbolic link. The target need not exist. ``` Returns true if f is readable - + ## `real-path` ``` clojure @@ -735,7 +735,7 @@ Returns true if f is readable ``` Converts f into real path via Path#toRealPath. - + ## `regular-file?` ``` clojure @@ -745,7 +745,7 @@ Converts f into real path via Path#toRealPath. ``` Returns true if f is a regular file, using Files/isRegularFile. - + ## `relative?` ``` clojure @@ -754,7 +754,7 @@ Returns true if f is a regular file, using Files/isRegularFile. ``` Returns true if f represents a relative path. - + ## `relativize` ``` clojure @@ -763,7 +763,7 @@ Returns true if f represents a relative path. ``` Returns relative path by comparing this with other. - + ## `same-file?` ``` clojure @@ -772,7 +772,7 @@ Returns relative path by comparing this with other. ``` Returns true if this is the same file as other. - + ## `set-attribute` ``` clojure @@ -780,7 +780,7 @@ Returns true if this is the same file as other. (set-attribute path attribute value) (set-attribute path attribute value {:keys [:nofollow-links]}) ``` - + ## `set-creation-time` ``` clojure @@ -790,7 +790,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). - + ## `set-last-modified-time` ``` clojure @@ -800,13 +800,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). - + ## `set-posix-file-permissions` - + ## `size` ``` clojure @@ -815,7 +815,7 @@ Sets last modified time of f to time (millis, java.time.Instant or java.nio.file ``` Returns the size of a file (in bytes). - + ## `split-ext` ``` clojure @@ -827,7 +827,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. - + ## `split-paths` ``` clojure @@ -837,7 +837,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 ';'. - + ## `starts-with?` ``` clojure @@ -846,7 +846,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. - + ## `str->posix` ``` clojure @@ -857,7 +857,7 @@ Returns true if path this starts with path other. Converts a string to a set of PosixFilePermission. `s` is a string like `"rwx------"`. - + ## `strip-ext` ``` clojure @@ -867,7 +867,7 @@ Converts a string to a set of PosixFilePermission. ``` Strips extension via [`split-ext`](#babashka.fs/split-ext). - + ## `sym-link?` ``` clojure @@ -876,7 +876,7 @@ Strips extension via [`split-ext`](#babashka.fs/split-ext). ``` Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`. - + ## `temp-dir` ``` clojure @@ -885,7 +885,7 @@ Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`. ``` Returns `java.io.tmpdir` property as path. - + ## `unixify` ``` clojure @@ -894,7 +894,7 @@ Returns `java.io.tmpdir` property as path. ``` Returns path as string with Unix-style file separators (`/`). - + ## `unzip` ``` clojure @@ -908,7 +908,7 @@ Unzips `zip-file` to `dest` directory (default `"."`). Options: * `:replace-existing` - `true` / `false`: overwrite existing files - + ## `update-file` ``` clojure @@ -923,7 +923,7 @@ Updates the contents of text file [`path`](#babashka.fs/path) using `f` applied Options: * `:charset` - charset of file, default to "utf-8" - + ## `walk-file-tree` ``` clojure @@ -936,7 +936,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. - + ## `which` ``` clojure @@ -955,7 +955,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. - + ## `which-all` ``` clojure @@ -965,7 +965,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). - + ## `windows?` ``` clojure @@ -974,7 +974,7 @@ Returns every Path to `program` found in ([`exec-paths`](#babashka.fs/exec-paths ``` Returns true if OS is Windows. - + ## `with-temp-dir` ``` clojure @@ -989,7 +989,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. - + ## `writable?` ``` clojure @@ -998,7 +998,7 @@ Evaluate body with binding-name bound to a temporary directory. ``` Returns true if f is writable - + ## `write-bytes` ``` clojure @@ -1021,7 +1021,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}) ``` - + ## `write-lines` ``` clojure @@ -1041,7 +1041,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`. - + ## `xdg-cache-home` ``` clojure @@ -1054,7 +1054,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. - + ## `xdg-config-home` ``` clojure @@ -1067,7 +1067,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. - + ## `xdg-data-home` ``` clojure @@ -1080,7 +1080,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. - + ## `xdg-state-home` ``` clojure @@ -1093,7 +1093,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. - + ## `zip` ``` clojure @@ -1110,4 +1110,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. - + diff --git a/CHANGELOG.md b/CHANGELOG.md index adb6de0..b74c462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ For a list of breaking changes, check [here](#breaking-changes). Babashka [fs](https://github.com/babashka/fs): file system utility library for Clojure +## v0.5.23 (2024-12-04) + +- [#135](https://github.com/babashka/fs/issues/135): preserve protocol when calling `fs/path` on multiple arguments ([@mk](https://github.com/mk)) + ## v0.5.22 (2024-08-05) - [#130](https://github.com/babashka/fs/issues/130) Unclear from `fs/glob` docs that it supports a `:max-depth` option ([@teodorlu](https://github.com/teodorlu)) diff --git a/project.clj b/project.clj index b396872..d6c83f6 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject babashka/fs "0.5.22" +(defproject babashka/fs "0.5.23" :description "Babashka file system utilities." :url "https://github.com/babashka/fs" :scm {:name "git"