OTX Reference  
OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite Class Reference

Opens a File on the specified path with write access. More...

Inheritance diagram for OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite:
Inheritance graph

Public Attributes

BooleanTerm append
 Cardinality [0..1]
This parameter is only effective when opening an existing file. If true, the resulting FileWriteHandle will initially contain the original contents of the file. If false, the FileWriteHandle will be created without initial content. If the element is not set, the default value false applies. More...
 
EncodingTerm encoding
 Cardinality [0..1]
This represents the encoding to be used. The set of standard encodings, which shall be supported by any runtime system is given by the Encoding enumeration in StringUtil extension, see ISO 13209-3. If the encoding is not specified, it assumes that Strings will be encoded using UTF-8. The encodings HEX, BIN, OCT are not allowed. More...
 
StringTerm path
 Cardinality [1]
The file to open. The path shall be defined by a URI (see ISO 13209-2, Annex OTX home and URI recommendation). More...
 
- Public Attributes inherited from OpenTestSystem.Otx.Core.Terms.Term
MetaData metaData
 Cardinality [0..1]
The MetaData type allows tools to store additional, mainly tool-specific data. More...
 

Detailed Description

Opens a File on the specified path with write access.

The OpenFileForWrite term opens an File on the specified path with write access and returns a file handle to this file. If the directory does not exist, the directory and all ancestors shall be created automatically. The underlying runtime system may lock the file to prevent simultaneous reading or writing. For better exchangeability, it is recommended to avoid concurrent write access to a file which is already open for reading or writing.

Important: This term has a side-effect.

Checker rules
CheckerRule.File_Chk001 – No lazy evaluation on terms with side-effects
Exceptions
Exceptions.FileAccessExceptionIf access to the file is not allowed, e.g. due to file system permissions.
Exceptions.FileOpenExceptionIf the open operation failed, or an encoding HEX, BIN, OCT is used.
Exceptions.FileNotFoundExceptionIf the path (file or directory) does not point to an existing file.
Exceptions.FileLockExceptionIf the underlying runtime system denies concurrent access.
Syntax
FileWriteHandleTerm = File.OpenFileForWrite(StringTerm path, BooleanTerm append = false, EncodingTerm encoding = @Encoding:UTF-8);
Examples
// Local Declarations
File.FileWriteHandle FileWriteHandle1;
// Flow
FileWriteHandle1 = File.OpenFileForWrite("file:///D:/abc.txt", false, @Encoding:UTF-8);

Member Data Documentation

◆ append

BooleanTerm OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.append

Cardinality [0..1]
This parameter is only effective when opening an existing file. If true, the resulting FileWriteHandle will initially contain the original contents of the file. If false, the FileWriteHandle will be created without initial content. If the element is not set, the default value false applies.

Note: The append flag has no influence on other actions that use the opened FileWriteHandle.

◆ encoding

EncodingTerm OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.encoding

Cardinality [0..1]
This represents the encoding to be used. The set of standard encodings, which shall be supported by any runtime system is given by the Encoding enumeration in StringUtil extension, see ISO 13209-3. If the encoding is not specified, it assumes that Strings will be encoded using UTF-8. The encodings HEX, BIN, OCT are not allowed.

◆ path

StringTerm OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.path

Cardinality [1]
The file to open. The path shall be defined by a URI (see ISO 13209-2, Annex OTX home and URI recommendation).

OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.encoding
EncodingTerm encoding
Cardinality [0..1] This represents the encoding to be used. The set of standard encodings,...
Definition: File.cs:1335
OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.path
StringTerm path
Cardinality [1] The file to open. The path shall be defined by a URI (see ISO 13209-2,...
Definition: File.cs:1313
OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForWrite.append
BooleanTerm append
Cardinality [0..1] This parameter is only effective when opening an existing file....
Definition: File.cs:1325