File Functions
Functions for reading, writing, and inspecting files
These functions have a File or Directory as an input and/or output. Due to type coercion, File or Directory arguments may be specified as String values.
For functions that read from or write to the file system, if the entire contents of the file cannot be read/written for any reason, the calling task or workflow fails with an error. Examples of failure include, but are not limited to, not having appropriate permissions, resource limitations (e.g., memory) when reading the file, and implementation-imposed file size limits.
For functions that write to the file system, the implementation should generate a random file name in a temporary directory so as not to conflict with any other task output files.
Restrictions
- A function that only manipulates a path (i.e., doesn't require reading any of the file's attributes or contents) may be called anywhere, whether or not the file exists.
- A function that reads a file or its attributes may only be called in a context where the input file exists. If the file is an input to a task or workflow, then it may be read anywhere in that task or workflow. If the file is created by a task, then it may only be read after it is created. For example, if the file is written during the execution of the
command, then it may only be read in the task'soutputsection. This includes functions likestdoutandstderrthat read a task's output stream. - A function that writes a file may be called anywhere. However, writing a file in a workflow is discouraged since it may have the side-effect of creating a permanent output file that is not named in the output section.