automaton-build.os.file
Tools to manipulate local files
Is a proxy to babashka.fs tools.
actual-copy
(actual-copy copy-actions)
Do the actual copy of copy-actions
.
combine-files
(combine-files target-filename & filenames)
Read text content of files filenames
and combine them into target-filename
.
copy-actions
(copy-actions file-rich-list src-dir dst-dir options)
For all file-rich-list
, adds a relative-path
and a target-dir-path
.
copy-dir
(copy-dir src-path dst-path options)
copy-file
(copy-file src-path dst-path options)
create-sym-link
(create-sym-link path target)
Creates a sym link to target
linking to path
.
create-temp-dir
(create-temp-dir & sub-dirs)
Returns a subdirectory path string of the system temporary directory. sub-dirs
is an optional list of strings, each one is a sub directory.
create-temp-file
(create-temp-file & filename)
Create a temporary file with filename
name of the file (optional).
delete-dir
(delete-dir dir)
Deletes dir
and returns it. If dir
does not exist, returns nil
delete-file
(delete-file filename)
Deletes filename
and returns it. If filename
does not exist, returns nil.
delete-path
(delete-path path)
Deletes path
and returns it. Returns nil if the path
does not exists.
empty-dir
(empty-dir path)
Empty the directory path
.
ensure-dir-exists
(ensure-dir-exists path)
Creates directory dir
if not already existing.
expand-home-str
(expand-home-str str)
In string str
, ~ is expanded to the actual value of home directory.
file-rich-list
(file-rich-list paths)
Returns, for each element in the paths
, return a rich file description with :
- with
path
copied here, :exists?
key check the existence of the file.-
and one of:
- for a directory,
:dir?
key is true, - for a file,
:file?
key is true.
is-existing-dir?
(is-existing-dir? dirname)
Check if this the path exist and is a directory.
is-existing-file?
(is-existing-file? filename)
Returns true if filename
path already exist and is not a directory.
is-existing-path?
(is-existing-path? path)
Returns true if filename
path already exist.
make-executable
(make-executable filename)
Make file filename
executable.
matching-files
(matching-files dir file-pattern)
Match files recursively found in dir
that are matching file-pattern
.
modified-since
(modified-since anchor file-set)
Returns true
if anchor
is older than one of the file in file-set
.
pp-file
(pp-file filename file-content)
Pretty print the file.
read-file
(read-file filename)
Read the file named filename
.
Returns:
filename
raw-content
if file can be read.invalid?
totrue
whatever why.exception
if something wrong happened.
search-files
(search-files root-dir pattern options)
(search-files root-dir pattern)
Search files and dirs. * root-dir
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 dir file-or-dir)
Search file-or-dir
in the parents directories of dir
.
to-src-dst
(to-src-dst copy-actions)
Turns copy-action
into a list of pairs containing the source file first and destination file then.
write-file
(write-file filename content)
Write the text file filename
with its content
.
Returns the nil if succesful, map with :exception otherwise