auto-build.os.file

Tools to manipulate local files

Is a proxy to babashka.fs tools.

combine-files

(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.

copy-action

(copy-action path src-dirpath dst-dirpath options)(copy-action path src-dirpath dst-dirpath)

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-path

copy-dir

(copy-dir src-path dst-path)(copy-dir src-path dst-path options)

copy-file

(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

create-temp-dir

(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.

create-temp-file

(create-temp-file)(create-temp-file filepath)

Create a temporary file. - The file is stored in the system temporary directory. - The file is suffixed with filepath (optional).

delete-dir

(delete-dir dirpath)

Deletes the directory at dirpath and returns dirpath if deleted. Returns nil otherwise

delete-file

(delete-file filepath)

Deletes filepath and returns it. If filepath does not exist, returns nil.

delete-path

(delete-path path)

Deletes path and returns it. Returns nil if the path does not exists.

do-copy-action

(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)

ensure-dir-exists

(ensure-dir-exists dirpath)

Creates directory dirpath if not already existing. Return dirpath if succesful, nil if creation has failed

ensure-empty-dir

(ensure-empty-dir dirpath)

Ensure the directory dirpath is existing and empty.

expand-home-str

(expand-home-str path)

Return path where ~ is expanded to the actual value of the current home directory.

is-existing-dir?

(is-existing-dir? dirpath)

Returns dirpath if this the path exists and is a directory.

is-existing-file?

(is-existing-file? filepath)

Returns the filepath if it already exists and is a regular file. Returns nil otherwise.

is-existing-path?

(is-existing-path? path)

Returns true if path path already exist.

make-executable

(make-executable filepath)

Make file filepath executable. Returns filepath

matching-files

(matching-files dirpath file-pattern)

Match files recursively found in dirpath that are matching file-pattern.

modified-since

(modified-since anchor-filepath file-set)

Returns true if anchor-filepath is older than one of the file in file-set.

path-on-disk

(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?

pp-file

(pp-file filepath file-content)

Pretty print content file-content into file filepath.

read-file

(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: * 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

(search-files dirpath pattern options)(search-files dirpath pattern)

Search 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 * options (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 directory

search-in-parents

(search-in-parents dirpath file-or-dir)

Search file-or-dir in the parents directories of dirpath.

write-file

(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)