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. If Path 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 with Extension.

meth (Target: file) - (Source: file): string | nil

Returns the relative path of Target in Source, or nil if Target is not contained in Source.

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 returns nil.

meth (Target: file):basename: string

Returns the filename component of Target.

meth (Directory: file):chdir: file

Changes the current directory to Directory. Returns Directory.

meth (Source: file):copy(Dest: file): nil

Copies the contents of Source to Dest.

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 (unlike Target:dir).

meth (Target: file):exists: file | nil

Returns Target if the file or directory exists or has a build function defined, otherwise returns nil.

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 in Source applied to Dest, or an error if Target is not contained in Source.

meth (Directory: file):mkdir: file

Creates the all directories in the path of Directory. Returns Directory.

meth (Target: file):open(Mode: string): stream

Opens the file at Target with mode Mode.

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 returns nil.

meth (Target: file):rmdir: file

Removes Target recursively. Returns Directory.