Difference between revisions of "Extensions.File.OpenFileForRead"

From emotive
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:OTX '''OpenFileForRead'''}}Category:File == Classification == {{ClassificationActivity | OpenFileForRead | UPDATING... | Term | Extensions.File|OTX Fi...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:OTX '''OpenFileForRead'''}}[[Category:File]]
 
{{DISPLAYTITLE:OTX '''OpenFileForRead'''}}[[Category:File]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | OpenFileForRead | UPDATING... | [[Term]] | [[Extensions.File|OTX File extension]] | UPDATING... | UPDATING... | UPDATING... }}
+
{{ClassificationActivity | OpenFileForRead| Opens a File and returns a file handle to this file | [[Term]] | [[Extensions.File|OTX File extension]] | [[Extensions.File#Terms|File related Terms]]| [[Extensions.File.FileLockException|FileLockException]] <br/>[[Extensions.File.FileNotFoundException|FileNotFoundException]] <br/> [[Extensions.File.FileOpenException|FileOpenException]]| - |}}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
DiagCom.CloseComChannel(ComChannelVariable);
+
FileReadHandleTerm File.OpenFileForRead(StringTerm path, EncodingTerm encoding);
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== Description ==
 
== Description ==
UPDATING...<!--
+
The '''OpenFileForRead''' activity opens a File on the specified path with read access and returns a file handle to this file. If a file is opened for reading it shall be automatically locked against writing. Simultaneous reading of the same file is possible.
OTX CloseComChannel activity is used for the [[Diagnosis Runtime System]] to announce that an open communication channel that all relevant resources can be released and closed.
+
 
{{ComChannelMemoryUsageNote}}
+
{{TermReturnValue| [[Extensions.File.FileReadHandle|FileReadHandle]] | Returns a file handle for the file in the specified path.}}
{{Important|Please note that the use of a shared '''ComChannel''' can bring the OTX runtime system in an undefined state and that is this case is not validated at design time!}}
 
-->
 
  
 
== Properties ==
 
== Properties ==
UPDATING...<!--
 
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| ComChannel | [[Extensions.DiagCom.ComChannel|ComChannel]] | [[Variable]] | - | [1] | Communication Channel (Control unit).}}
+
{{TableRowPropertie1| Encoding| [[Extensions.StringUtil.Encoding|Encoding]] | [[Term]] | - | [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 [[Extensions.StringUtil|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.}}
 +
{{TableRowPropertie2| Path| [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1..1] |The file to open. The path parameter is permitted to specify relative or absolute path information.}}
 
|}
 
|}
-->
 
  
 
== OTL Examples ==
 
== OTL Examples ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
DiagCom.ComChannel myComCannel;
+
/// Local Declarations
 +
 
 +
File.FileReadHandle FileReadHandle1;
  
myComCannel = DiagCom.GetComChannel("DiagnosticsCan_ECU_1", null, false);
+
/// Flow
  
// Code example using the variable myComChannel
+
FileReadHandle1 = File.OpenFileForRead("file:///D:/abc.txt", @Encoding:UTF-8);
// ...
 
DiagCom.CloseComChannel(myComCannel);</syntaxhighlight>
 
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== See also ==
 
== See also ==
UPDATING...
+
[[Extensions.File.CreateTempDirectory|CreateTempDirectory]]<br/>
 +
[[Extensions.File.GetFilePath|GetFilePath]]<br/>
 +
[[Extensions.File.GetFilesFromDirectory|GetFilesFromDirectory]]<br/>
 +
[[Extensions.File.GetFileSize|GetFileSize]]<br/>
 +
[[Extensions.File.IsDirectory|IsDirectory]]<br/>
 +
[[Extensions.File.IsEndOfFileReached|IsEndOfFileReached]]<br/>
 +
[[Extensions.File.IsFile|IsFile]]<br/>
 +
<!--[[Extensions.File.OpenFileForRead|OpenFileForRead]]<br/>-->
 +
[[Extensions.File.OpenFileForWrite|OpenFileForWrite]]<br/>
 +
[[Extensions.File.ReadBytes|ReadBytes]]<br/>
 +
[[Extensions.File.ReadFile|ReadFile]]<br/>
 +
[[Extensions.File.ReadLine|ReadLine]]

Latest revision as of 10:29, 2 November 2018

Classification

Name OpenFileForRead
Short Description Opens a File and returns a file handle to this file
Class Term
Extension OTX File extension
Group File related Terms
Exceptions FileLockException
FileNotFoundException
FileOpenException
Checker Rules -
Standard Compliant Yes

OTL Syntax

FileReadHandleTerm File.OpenFileForRead(StringTerm path, EncodingTerm encoding);

Description

The OpenFileForRead activity opens a File on the specified path with read access and returns a file handle to this file. If a file is opened for reading it shall be automatically locked against writing. Simultaneous reading of the same file is possible.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
FileReadHandle Returns a file handle for the file in the specified path.

Properties

Name Data Type Class Default Cardinality Description
Encoding Encoding Term - [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 String Term - [1..1] The file to open. The path parameter is permitted to specify relative or absolute path information.

OTL Examples

/// Local Declarations

File.FileReadHandle FileReadHandle1;

/// Flow

FileReadHandle1 = File.OpenFileForRead("file:///D:/abc.txt", @Encoding:UTF-8);

See also

CreateTempDirectory
GetFilePath
GetFilesFromDirectory
GetFileSize
IsDirectory
IsEndOfFileReached
IsFile
OpenFileForWrite
ReadBytes
ReadFile
ReadLine