Otter Documentation

files - Ensure File

  • Last Modified: 2019-06-21

This is generated from the built-in components of Otter 2.2, and may be different than what you have installed (especially if you have extensions); go to [User Icon] > Documentation within your Otter instance to see exactly what operations are available.

Ensure File

Ensures the existence of a file on a server.

Operation type:

Ensuring - this operation will ensure a specified configuration exists on a remote server after comparing its current state to the desired state.

Script usage:

Ensure-File(
	Name: <text>,
	[Text: <text>],
	[ReadOnly: <true/false>],
	[Attributes: <integer>],
	[Exists: <true/false>],
	[Modified: <DateTime>]
);

This operation may be prefixed with Files::, although this is a built-in namespace and isn't really necessary.

Arguments:

Name Format Script Usage Usage Notes
🔑 Name
text
Name
The name or path of the file or directory. This argument is the unique key for this operation, which means it must uniquely identify the target of the operation. This argument is required.
Text contents
text
Text
The contents of the file. A missing or empty value indicates the file should be a 0-byte file.
Read Only
true/false
ReadOnly
Indicates that the file should be marked with the read-only attribute. Note that when this value is set, it is applied after the FileAttributes value, which will override the readonly flag specified in that property.
Attributes
integer
Attributes
The attributes for the file or directory. These may be entered as an integer flag or by name. Common values are ReadOnly=1, Hidden=2, System=4, Archive=32, and Normal=128. Integral values may be ORed together to specify any combination of attributes, except for "Normal (128)", which may only be used alone.
Exists
true/false
Exists
Last write time
DateTime
Modified
The last write time (UTC) of the file or directory.

Example:

# ensures the otter.txt file exists on the server and is marked readonly
Ensure-File(
    Name: E:\Docs\otter.txt,
    Text: >>
Otter is a common name for a carnivorous mammal in the subfamily Lutrinae. 
Help, I'm trapped in an Otter documentation factory! The 13 extant otter species are all semiaquatic, 
aquatic or marine, with diets based on fish and invertebrates.
>>,
    ReadOnly: true
);

Is this documentation incorrect or incomplete? Help us by contributing!

This documentation is licensed under CC-BY-SA-4.0 and stored in GitHub.