Namespace src/File
src/File
Overview
Directory src/File
file source src/File/concatenatePath.sh
File::concatenatePath
concatenate 2 paths and ensure the path is correct using realpath -m
Arguments
- $1 basePath:String
- $2 subPath:String
Requires
- Linux::requireRealpathCommand
src/File/detectBashFile.sh
file source src/File/detectBashFile.sh
File::detectBashFile
check if file provided is a bash file
Arguments
- $@ files:String[]
Variables set
- missingBashFileList (String): temp filepath that contains eventual missing files
Output on stdout
- filepath if Assert::bashFile succeed
See also
src/File/elapsedTimeSinceLastModification.sh
file source src/File/elapsedTimeSinceLastModification.sh
File::elapsedTimeSinceLastModification
get number of seconds since last modification of the file
Arguments
- $1 (file:String): file path
Exit codes
- 1: if file does not exist
Output on stdout
- number of seconds since last modification of the file
src/File/garbageCollect.sh
file source src/File/garbageCollect.sh
File::garbageCollect
delete files older than n days in given path
Arguments
- $1 (path:String): the directory in which files will be deleted or the file to delete
- $2 (mtime:String): expiration time in days (eg: 1 means 1 day) (default value: 1). Eg: +1 match files that have been accessed at least two days ago (rounding effect)
- $3 (maxdepth:int): Descend at most levels (a non-negative integer) levels of directories below the starting-points. (default value: 1)
Exit codes
- 1: if path not provided or empty
- find command failure code
Output on stderr
- find output on error or diagnostics logs
Warnings
- use this function with caution as it will delete all files in given path without any prompt
See also
src/File/getAbsolutePath.sh
file source src/File/getAbsolutePath.sh
File::getAbsolutePath
get absolute file from relative path
Arguments
- $1 (file:String): relative file path
Output on stdout
- absolute path (can be $1 if $1 begins with /)
src/File/insertFileAfterToken.sh
file source src/File/insertFileAfterToken.sh
File::insertFileAfterToken
insert file content inside another file after a pattern
Arguments
- $1 (file:String): file in which fileToImport will be
- $2 (fileToImport:String): file to inject before the
- $3 (token:String): token needs to be properly escaped
src/File/insertFileBeforeToken.sh
file source src/File/insertFileBeforeToken.sh
File::insertFileBeforeToken
insert file content inside another file before a pattern
Arguments
- $1 (file:String): file in which fileToImport will be
- $2 (fileToImport:String): file to inject before the
- $3 (token:String): token needs to be properly escaped
src/File/relativeToDir.sh
file source src/File/relativeToDir.sh
File::relativeToDir
print the resolved path relative to DIR do not check for path existence
Arguments
- $1 (srcFile:String): the file to resolve
- $2 (relativeTo:String): the directory
Output on stdout
- the resolved path relative to DIR
src/File/replaceTokenByInput.sh
file source src/File/replaceTokenByInput.sh
File::replaceTokenByInput
replace token by input(stdin) in given targetFile
Arguments
- $1 (token:String): the token to replace by stdin
- $2 (targetFile:String): the file in which token will be replaced by stdin
Exit codes
- 1: if error
Input on stdin
- the file content that will be injected in targetFile
Warnings
- special ansi codes will be removed from stdin
src/File/upFind.sh
file source src/File/upFind.sh
File::upFind
search a file in parent directories
Arguments
- $1 (fromPath:String): path
- $2 fileName:String
- $3 (untilInclusivePath:String): (optional) find for given file until reaching this folder (default value: /)
- … (untilInclusivePaths:String[]): list of untilInclusivePath
Exit codes
- 1: if the command failed or file not found
Output on stdout
- The filename if found