Reference: Files¶
Usage¶
Overview
This module offers a set of utilities for common file operations, including file manipulation, directory handling, and basic file management. It focuses on simplicity and clarity, making it easy to perform tasks like deleting files, moving data, or downloading resources.
Key Functions
- File/Directory Management: Create directories, move files, delete files (with glob support).
- File Operations: Download files, make files executable, read file contents.
- Contextual Tools: Work within specific directories or scripts.
Examples
- Delete multiple files:
- Download a file:
- Make a file executable:
Commands Reference¶
files.appendLine¶
Appends Line to provided file
files.appendLine
f ?args?
Parameters¶
f |
Target file |
args |
joined to a default string with join |
files.appendText¶
Appends test to provided file
files.appendText
f ?args?
Parameters¶
f |
Target file |
args |
joined to a default string with join |
files.compressDir¶
Compress dir into output archive @arg --rename , input dir will be renamed to out file name in output tar
files.compressDir
dir out ?args?
Parameters¶
dir |
Not documented. |
out |
Not documented. |
files.cp¶
Copy file to directory
files.cp
f dir
Parameters¶
f |
source file |
dir |
target directory |
files.cpSubst¶
files.cpSubst
files dir
Parameters¶
files |
Not documented. |
dir |
Not documented. |
files.delete¶
Delete provided files in the args list - if a file is not a regular file or directory, the argument is treated as a glob to delete multiple files at once
files.delete
?args?
Parameters¶
args |
paths to files/directories or glob to be deleted |
Description¶
Examples:
files.download¶
Download source file to target file using wget
files.download
src ?out?
Parameters¶
src |
Not documented. |
out |
Not documented. Optional, default "" . |
files.downloadOrRefresh¶
Downloads file from the URL if needed, or if refresh key is set
files.downloadOrRefresh
url refresh ?outFile?
Parameters¶
url |
Not documented. |
refresh |
Not documented. |
outFile |
Not documented. Optional, default "" . |
files.extract¶
files.extract
f ?args?
Parameters¶
f |
Not documented. |
files.extractAndDelete¶
files.extractAndDelete
f ?args?
Parameters¶
f |
Not documented. |
files.getScriptDirectory¶
Returns the directory of the current running script
files.getScriptDirectory
?args?
Parameters¶
Return value¶
Returns the directory of the current running script
files.globAll¶
files.globAll
?args?
Parameters¶
files.globFiles¶
files.globFiles
?args?
Parameters¶
Description¶
files.globFolders¶
files.globFolders
?args?
Parameters¶
Description¶
files.inBuildDirectory¶
files.inBuildDirectory
d script
Parameters¶
d |
Not documented. |
script |
Not documented. |
files.inDirectory¶
files.inDirectory
d script
Parameters¶
d |
Not documented. |
script |
Not documented. |
files.isAbsolute¶
Returns true if path is absolute
files.isAbsolute
path
Parameters¶
path |
Not documented. |
Return value¶
Returns true if path is absolute
files.isEmpty¶
Returns true if path is a folder and empty
files.isEmpty
path
Parameters¶
path |
Not documented. |
Return value¶
Returns true if path is a folder and empty
files.isExecutable¶
Returns true if a file is executable for the owner by default
files.isExecutable
f ?for?
Parameters¶
f |
Not documented. |
for |
pass -group or -other or -user to check specific group execution Optional, default -user . |
Return value¶
Returns true if a file is executable for the owner by default
files.isFile¶
Returns true if path is a file and exists
files.isFile
path
Parameters¶
path |
Not documented. |
Return value¶
Returns true if path is a file and exists
files.isFolder¶
Returns true if path is a folder and exists
files.isFolder
path
Parameters¶
path |
Not documented. |
Return value¶
Returns true if path is a folder and exists
files.isRelative¶
Returns true if path is relative
files.isRelative
path
Parameters¶
path |
Not documented. |
Return value¶
Returns true if path is relative
files.joinWithPathSeparator¶
files.joinWithPathSeparator
?args?
Parameters¶
Description¶
files.makeAbsoluteTo¶
Returns an absolute path, if path is relative, make it absolute relative to base
files.makeAbsoluteTo
path base
Parameters¶
path |
Not documented. |
base |
Not documented. |
Return value¶
Returns an absolute path, if path is relative, make it absolute relative to base
files.makeExecutable¶
Makes a file executable by setting user permissin to +x
files.makeExecutable
f ?args?
Parameters¶
f |
Not documented. |
files.mkdir¶
Create directory
files.mkdir
dir
Parameters¶
dir |
path to directory to be created |
files.moveFileToTemp¶
Reads and write provided file to a tempfile
files.moveFileToTemp
f
Parameters¶
f |
Source file path |
Description¶
If a file is in Zipfs archive but needs to be used by an external command for example, move it to a temporary file on host
Return value¶
Returns the path to the created temp file
files.mv¶
files.mv
src dst
Parameters¶
src |
Not documented. |
dst |
Not documented. |
files.read¶
files.read
f
Parameters¶
f |
Not documented. |
files.require¶
Require File, if not present, run script
files.require
f script
Parameters¶
f |
File to be required |
script |
Script to be evaluated if the file is not present |
files.requireOrForce¶
files.requireOrForce
f script
Parameters¶
f |
Not documented. |
script |
Not documented. |
files.requireOrRefresh¶
Executes $script
if the provided file $f
doesn't exist, or the refresh key $key
was requested
files.requireOrRefresh
f key script
Parameters¶
f |
path of file to check for existence |
key |
the key provided by user to kissb as argument --refresh-key to force file refresh |
script |
Script executed, user must ensure it creates the requested file. File path is passed as ${__f} variable |
Description¶
Doesn't return anything.
files.sha256¶
Checksum the provided file and write to a .sha256 file
files.sha256
file ?args?
Parameters¶
file |
Sourec file to checksum |
args |
Use -nowrite to not write the sha to the file output |
Return value¶
Returns the calculated sha if -nowrite, or the path to checksum file
files.tarDir¶
files.tarDir
dir out ?args?
Parameters¶
dir |
Not documented. |
out |
Not documented. |
files.untar¶
files.untar
f ?args?
Parameters¶
f |
Not documented. |
files.unzip¶
Unzip
files.unzip
f ?args?
Parameters¶
f |
Not documented. |
files.withGlobAll¶
files.withGlobAll
?args? script
Parameters¶
script |
Not documented. |
files.withGlobFiles¶
files.withGlobFiles
?args? script
Parameters¶
script |
Not documented. |
files.withWriter¶
Files writer
files.withWriter
outPath script
Parameters¶
outPath |
Not documented. |
script |
Not documented. |
files.writer.indent¶
files.writer.indent
?args?
Parameters¶
files.writer.outdent¶
files.writer.outdent
?args?
Parameters¶
files.writer.print¶
files.writer.print
?args?
Parameters¶
files.writer.printLine¶
files.writer.printLine
?args?
Parameters¶
files.writer.println¶
files.writer.println
?args?
Parameters¶
files.writeText¶
Writes text to provided file
files.writeText
f ?args?
Parameters¶
f |
Target file |
args |
joined to a default string with join |
files.zipDir¶
files.zipDir
dir out ?args?
Parameters¶
dir |
Not documented. |
out |
Not documented. |