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

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

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

Public Attributes

EncodingTerm encoding
 Cardinality [0..1]
This represents the encoding to be used. 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 read access.

The OpenFileForRead term opens an File on the specified path with read access and returns a file handle to this file. If a file is opened for reading, the underlying runtime system may lock the file against writing. For better exchangeability, it is recommended to avoid concurrent read access to a file which is already open for writing. Simultaneous reading of the same file is possible.

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
FileReadHandleTerm = File.OpenFileForRead(StringTerm path, EncodingTerm encoding = @Encoding:UTF-8);
Examples
// Local Declarations
File.FileReadHandle FileReadHandle1;
// Flow
FileReadHandle1 = File.OpenFileForRead("file:///D:/abc.txt", @Encoding:UTF-8);

Member Data Documentation

◆ encoding

EncodingTerm OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForRead.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. 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.OpenFileForRead.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.OpenFileForRead.path
StringTerm path
Cardinality [1] The file to open. The path shall be defined by a URI (see ISO 13209-2,...
Definition: File.cs:1462
OpenTestSystem.Otx.Extensions.File.Terms.OpenFileForRead.encoding
EncodingTerm encoding
Cardinality [0..1] This represents the encoding to be used.
Definition: File.cs:1478