This object is created during the analysis phase to represent a file or directory that will be read or written during the execution phase. It is not an open file handle, and cannot be used to directly read or write file contents. Rather, you use it to construct the action graph in a rule implementation function by passing it to action-creating functions. See the Rules page for more information.
When a File
is passed to an Args
object without using a map_each
function, it is converted to a string by taking the value of its path
field.
Members
- basename
- dirname
- extension
- is_directory
- is_source
- is_symlink
- owner
- path
- root
- short_path
- tree_relative_path
basename
string File.basename
dirname
string File.dirname
extension
string File.extension
is_directory
bool File.is_directory
is_source
bool File.is_source
is_symlink
bool File.is_symlink
owner
Label File.owner
None
.
path
string File.path
short_path
. The root may be empty, which it usually is for non-generated files. For generated files it usually contains a configuration-specific path fragment that encodes things like the target CPU architecture that was used while building said file. Use the short_path
for the path under which the file is mapped if it's in the runfiles of a binary.
root
root File.root
short_path
string File.short_path
tree_relative_path
string File.tree_relative_path
tree_relative_path
is only available for expanded files of a directory in an action command, i.e. Args.add_all(). For other types of files, it is an error to access this field.