fileΒΆ
type file < target
A file target represents a single file or directory in the filesystem. File targets are stored relative to the project root whenever possible, taking into account virtual mounts. They are automatically resolving to absolute paths when required.
fun file(Path: string, BuildFn?: any): file
Returns a new file target. If
Path
does not begin with /, it is considered relative to the current context path. IfPath
is specified as an absolute path but lies inside the project directory, it is converted into a relative path.meth (File: file) % (Extension: string): file
Returns a new file target by replacing the extension of
File
withExtension
.meth (Target: file) - (Source: file): string | nil
Returns the relative path of
Target
inSource
, ornil
ifTarget
is not contained inSource
.meth (Directory: file) / (Name: string): file
Returns a new file target at
Directory
/
Name
.meth (Target: file):absolute: target | nil
Returns
Target
if is has an absolute path, otherwise returnsnil
.meth (Target: file):basename: string
Returns the filename component of
Target
.meth (Directory: file):chdir: file
Changes the current directory to
Directory
. ReturnsDirectory
.meth (Source: file):copy(Dest: file): nil
Copies the contents of
Source
toDest
.meth (Target: file):dir: file
Returns the directory containing
Target
.meth (Target: file):dirname: string
Returns the directory containing
Target
as a string. Virtual mounts are not applied to the result (unlikeTarget:dir
).meth (Target: file):exists: file | nil
Returns
Target
if the file or directory exists or has a build function defined, otherwise returnsnil
.meth (Target: file):extension: string
Returns the file extension of
Target
.meth (Directory: file):ls(Pattern?: string|regex, Recursive?: method, Filter?: function, ...): list[target]
Returns a list of the contents of
Directory
. Passing:R
results in a recursive list.meth (Target: file):map(Source: file, Dest: file): file | error
Returns the relative path of
Target
inSource
applied toDest
, or an error ifTarget
is not contained inSource
.meth (Directory: file):mkdir: file
Creates the all directories in the path of
Directory
. ReturnsDirectory
.meth (Target: file):open(Mode: string): stream
Opens the file at
Target
with modeMode
.meth (Target: file):path: string
Returns the internal (possibly unresolved and relative to project root) path of
Target
.meth (Target: file):relative: target | nil
Returns
Target
if is has a relative path, otherwise returnsnil
.meth (Target: file):rmdir: file
Removes
Target
recursively. ReturnsDirectory
.