Tools to manipulate local files
Is a proxy to babashka.fs tools.
Tools to manipulate local files Is a proxy to babashka.fs tools.
(combine-files printers target-filepath & src-filepathes)Read text content of files src-filepathes - in the order of the sequence - and combine them into target-filepath.
Read text content of files `src-filepathes` - in the order of the sequence - and combine them into `target-filepath`.
(copy-action path src-dirpath dst-dirpath)(copy-action path src-dirpath dst-dirpath options)Copy a file at path in a subdir of src-dirpath to dst-dirpath.
The options could be :replace-existing :copy-attributes. Returns:
:path given path:apath the absolute path:type could be :file :directory:exist?:dst-dirpath:options:relative-path:target-pathCopy a file at `path` in a subdir of `src-dirpath` to `dst-dirpath`. The `options` could be `:replace-existing` `:copy-attributes`. Returns: * `:path` given path * `:apath` the absolute path * `:type` could be `:file` `:directory` * `:exist?` * `:dst-dirpath` * `:options` * `:relative-path` * `:target-path`
(copy-file src-filepath dst-path options)Copy src-filepath to dst-path, that could be a filepath, or a directory where the file will be stored.
Returns nil
Copy `src-filepath` to `dst-path`, that could be a filepath, or a directory where the file will be stored. Returns `nil`
(create-sym-link filepath target)Creates a sym link to target linking to filepath.
Returns filepath
Creates a sym link to `target` linking to `filepath`. Returns `filepath`
(create-temp-dir)(create-temp-dir sub-dir)Returns a subdirectory path string of the system temporary directory.
sub-dir is an optional string, each one is a sub directory.
Returns a subdirectory path string of the system temporary directory. `sub-dir` is an optional string, each one is a sub directory.
(create-temp-file)(create-temp-file filepath)Create a temporary file.
filepath (optional).Create a temporary file. - The file is stored in the system temporary directory. - The file is suffixed with `filepath` (optional).
(delete-dir dirpath)Deletes the directory at dirpath and returns dirpath if deleted. Returns nil otherwise
Deletes the directory at `dirpath` and returns `dirpath` if deleted. Returns `nil` otherwise
(delete-file filepath)Deletes filepath and returns it.
If filepath does not exist, returns nil.
Deletes `filepath` and returns it. If `filepath` does not exist, returns nil.
(delete-path path)Deletes path and returns it.
Returns nil if the path does not exists.
Deletes `path` and returns it. Returns nil if the `path` does not exists.
(do-copy-action {:keys [type path dst-dirpath target-path options exist?]
:as copy-action})Do the actual copy of copy-action, enrich it with :status (:copy-fail or :success)
Do the actual copy of `copy-action`, enrich it with `:status` (`:copy-fail` or `:success`)
(ensure-dir-exists dirpath)Creates directory dirpath if not already existing.
Return dirpath if succesful, nil if creation has failed
Creates directory `dirpath` if not already existing. Return `dirpath` if succesful, `nil` if creation has failed
(ensure-empty-dir dirpath)Ensure the directory dirpath is existing and empty.
Ensure the directory `dirpath` is existing and empty.
(expand-home-str path)Return path where ~ is expanded to the actual value of the current home directory.
Return `path` where `~` is expanded to the actual value of the current home directory.
(is-existing-dir? dirpath)Returns dirpath if this the path exists and is a directory.
Returns `dirpath` if this the path exists and is a directory.
(is-existing-file? filepath)Returns the filepath if it already exists and is a regular file. Returns nil otherwise.
Returns the `filepath` if it already exists and is a regular file. Returns `nil` otherwise.
(is-existing-path? path)Returns true if path path already exist.
Returns true if `path` path already exist.
(make-executable filepath)Make file filepath executable.
Returns filepath
Make file `filepath` executable. Returns `filepath`
(matching-files dirpath file-pattern)Match files recursively found in dirpath that are matching file-pattern.
Match files recursively found in `dirpath` that are matching `file-pattern`.
(modified-since anchor-filepath file-set)Returns true if anchor-filepath is older than one of the file in file-set.
Returns `true` if `anchor-filepath` is older than one of the file in `file-set`.
(path-on-disk path)Returns a map with informations on the existance of path as found on the disk.
As all path functions, it could be a file or a directory.
It returns:
:path given path:apath the absolute path:type could be :file :directory:exist?Returns a map with informations on the existance of `path` as found on the disk. As all `path` functions, it could be a file or a directory. It returns: * `:path` given path * `:apath` the absolute path * `:type` could be `:file` `:directory` * `:exist?`
(pp-file filepath file-content)Pretty print content file-content into file filepath.
Pretty print content `file-content` into file `filepath`.
(read-file {:keys [errorln uri-str exception-msg] :as _printers} filepath)Read the file named filepath.
Returns:
:filepath as given as a parameter:afilepath file with absolute path:status is :success or :file-loading-fail:raw-content (only if :status is :success):exception (only if :status is :file-loading-fail)That functions print on the cli:
Read the file named `filepath`. Returns: * `:filepath` as given as a parameter * `:afilepath` file with absolute path * `:status` is `:success` or `:file-loading-fail` * `:raw-content` (only if `:status` is `:success`) * `:exception` (only if `:status` is `:file-loading-fail`) That functions print on the cli: * nothing if successful or if printers are nil * an error message and the message of the exception if the file can't be read.
(search-files dirpath pattern)(search-files dirpath pattern options)Search files and dirs.
dirpath is where the root directory of the search-filespattern is a regular expression or a glob as described in java docoptions (Optional, default = {}) are boolean value for :hidden, :recursive and :follow-lins. See babashka fs for details.
For instance:(files/search-files "" "**{.clj,.cljs,.cljc,.edn}") search all clj file-paths in pwd directorySearch files and dirs.
* `dirpath` is where the root directory of the search-files
* `pattern` is a regular expression or a glob as described in [java doc](https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String))
* `options` (Optional, default = {}) are boolean value for `:hidden`, `:recursive` and `:follow-lins`. See [babashka fs](https://github.com/babashka/fs/blob/master/API.md#glob) for details.
For instance:
* `(files/search-files "" "**{.clj,.cljs,.cljc,.edn}")` search all clj file-paths in pwd directory(search-in-parents dirpath file-or-dir)Search file-or-dir in the parents directories of dirpath.
Search `file-or-dir` in the parents directories of `dirpath`.
(write-file filepath
{:keys [errorln exception-msg normalln uri-str] :as _printers}
content)Write the content in the file at filepath .
Returns
:filepath as given as a parameter:afilepath file with absolute path:status is :success or :file-writing-fail:raw-content if file can be read.:exception (only if :status is :file-writing-fail)Write the `content` in the file at `filepath` . Returns * `:filepath` as given as a parameter * `:afilepath` file with absolute path * `:status` is `:success` or `:file-writing-fail` * `:raw-content` if file can be read. * `:exception` (only if `:status` is `:file-writing-fail`)
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |