Tools to manipulate local files Is a proxy to babashka.fs tools
Tools to manipulate local files Is a proxy to babashka.fs tools
(absolutize relative-path)
Transform a file or dir name in an absolute path
Transform a file or dir name in an absolute path
(add-suffix filename suffix)
Add a suffix of the filename before the extension
Add a suffix of the filename before the extension
(change-extension file-name new-extension)
Change the extension
Change the extension
(compare-paths path1 path2)
Are the paths pointing to the same directory? Params:
path1
path2
Are the paths pointing to the same directory? Params: * `path1` * `path2`
(copy-files-or-dir files target-dir)
Copy the files, even if they are directories to the target
files
is a sequence of file or directory name, in absolute or relative formtarget-dir
is where files are copied toCopy the files, even if they are directories to the target * `files` is a sequence of file or directory name, in absolute or relative form * `target-dir` is where files are copied to
(create-dir-path & dirs)
Creates a path with the list of parameters. Removes the empty strings, add needed separators, including the trailing ones
Creates a path with the list of parameters. Removes the empty strings, add needed separators, including the trailing ones
(create-file-path & dirs)
Creates a path with the list of parameters. Removes the empty strings, add needed separators
Creates a path with the list of parameters. Removes the empty strings, add needed separators
(create-temp-dir & sub-dirs)
Creates a temporary directory managed by the system Params:
sub-dirs
is an optional list of strings, each one is a sub directory
Returns the string of the directory pathCreates a temporary directory managed by the system Params: * `sub-dirs` is an optional list of strings, each one is a sub directory Returns the string of the directory path
(delete-files file-list)
Deletes the files which are given in the list. They could be regular files or directory, when so the whole subtreee will be removed
Deletes the files which are given in the list. They could be regular files or directory, when so the whole subtreee will be removed
(delete-files-starting-with files-map starting-regexp)
Remove all files matching:
files-map
where the files are searchedstarting-regexp
is a regular expression matching the first line of the fileRemove all files matching: * `files-map` where the files are searched * `starting-regexp` is a regular expression matching the first line of the file
(directory-exists? directory-path)
Check directory existance
Check directory existance
Symbol to separate directories.
Is usually /
on linux based OS And \
on windows based ones
Symbol to separate directories. Is usually `/` on linux based OS And `\` on windows based ones
(empty-path? dir)
Is the directory empty Params:
dir
the directory to search inIs the directory empty Params: * `dir` the directory to search in
(ensure-directory-exists dir)
If directory doesn't exist, create it. Params:
dir
directory to checkIf directory doesn't exist, create it. Params: * `dir` directory to check
(extract-path filename)
Extract if the filename is a file, return the path that contains it, otherwise return the path itself
Extract if the filename is a file, return the path that contains it, otherwise return the path itself
(file-in-same-dir source-file relative-name)
Use the relative-name to create in file in the same directory than source-file
Use the relative-name to create in file in the same directory than source-file
(file-ized namespace)
Transform a name, like a namespace name or application name, in a directory compatible names
Transform a name, like a namespace name or application name, in a directory compatible names
(file-name path)
Return the file name without the path
Return the file name without the path
(file-prefix path)
Adds file:
as a prefix to the string. Usefull when java io resource type of path is needed
Adds `file:` as a prefix to the string. Usefull when java io resource type of path is needed
(filter-existing-dir dirs)
Filter only existing dirs Params:
dirs
sequence of string of directoriesFilter only existing dirs Params: * `dirs` sequence of string of directories
(for-each dir fn-each)
Apply fn-each on each files in a directory
Apply fn-each on each files in a directory
(hidden? path)
Return true if the path is hidden
Return true if the path is hidden
(is-existing-dir? path)
Check if this the path exist and is a directory
Check if this the path exist and is a directory
(is-existing-file? path)
Check if this the path exist and is not a directory
Check if this the path exist and is not a directory
(modified-since anchor file-set)
Return true if anchor is older than one of the file in file-set
Return true if anchor is older than one of the file in file-set
(read-file target-filename)
Read the file target-filename
Read the file `target-filename`
(relativize path root-dir)
Turn the path
into a relative directory starting from root-dir
Turn the `path` into a relative directory starting from `root-dir`
(remove-file filename)
Remove the file filename
Remove the file `filename`
(remove-trailing-separator path)
If exists, remove the trailing separator in a path, remove unwanted spaces either
If exists, remove the trailing separator in a path, remove unwanted spaces either
(rename-file src dst)
Rename a file src
to destination file dst
Rename a file `src` to destination file `dst`
(rename-recursively target-dir file-filter pattern pattern-replacement)
Search recursively all sub-dirs to be renamed from template-app
in the target-dir
directory
target-dir
is the root directory of the searched filesfile-filter
filter for files, according to syntax in crate regexp.pattern
is to find content in the namespace, for instance, as seen in java pattern, e.g. #"foo(.*)bar"pattern-replacement
is what to replace, according to the replace specification. e.g. "foo_$1_bar"Search recursively all sub-dirs to be renamed from `template-app` in the `target-dir` directory * `target-dir` is the root directory of the searched files * `file-filter` filter for files, [according to syntax in crate regexp](https://docs.rs/regex/1.9.1/regex/#syntax). * `pattern` is to find content in the namespace, for instance, as seen in [java pattern](https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html), e.g. #"foo(.*)bar" * `pattern-replacement` is what to replace, according to the [replace specification](https://clojuredocs.org/clojure.string/replace). e.g. "foo_$1_bar"
(search-files root pattern)
(search-files root pattern options)
Search files.
root
is where the root directory of the search-filespattern
is a regular expression 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 files in pwd directorySearch files. * `root` is where the root directory of the search-files * `pattern` is a regular expression 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 files in pwd directory
(write-file filename content)
Spit the file, the directory where to store the file is created if necessary
filename
is the name of the file to write, could be absolute or relativecontent
is the content to store thereSpit the file, the directory where to store the file is created if necessary * `filename` is the name of the file to write, could be absolute or relative * `content` is the content to store there
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close