Difference between revisions of "Extensions.File.OpenFileForWrite"

From emotive
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:OTX '''OpenFileForWrite'''}}Category:File == Classification == {{ClassificationActivity | OpenFileForWrite | UPDATING... | Term | Extensions.File|OTX...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:OTX '''OpenFileForWrite'''}}[[Category:File]]
 
{{DISPLAYTITLE:OTX '''OpenFileForWrite'''}}[[Category:File]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | OpenFileForWrite | UPDATING... | [[Term]] | [[Extensions.File|OTX File extension]] | UPDATING... | UPDATING... | UPDATING... }}
+
{{ClassificationActivity | OpenFileForWrite| 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);
+
FileWriteHandleTerm File.OpenFileForWrite(StringTerm path, BooleanTerm append, EncodingTerm encoding);
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== Description ==
 
== Description ==
UPDATING...<!--
+
The '''OpenFileForWrite''' activity opens a 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 file shall be automatically locked to prevent simultaneous reading or writing.
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.FileWriteHandle|FileWriteHandle]] | 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).}}
+
{{TableRowPropertie2| Append| [[Core.DataTypes.SimpleDataType.Boolean|Boolean]] | [[Term]] | - | [0..1] |This parameter is only effective when opening an existing file. If true, the resulting [[Extensions.File.FileWriteHandle|'''FileWriteHandle''']] will initially contain the original contents of the file. If false, the [[Extensions.File.FileWriteHandle|'''FileWriteHandle''']] will be created without initial content. If the element is not set, the default value false applies.}}
 +
{{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.FileWriteHandle FileWriteHandle1;
  
myComCannel = DiagCom.GetComChannel("DiagnosticsCan_ECU_1", null, false);
+
/// Flow
  
// Code example using the variable myComChannel
+
FileWriteHandle1 = File.OpenFileForWrite("file:///D:/abc.txt", false, @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:30, 2 November 2018

Classification

Name OpenFileForWrite
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

FileWriteHandleTerm File.OpenFileForWrite(StringTerm path, BooleanTerm append, EncodingTerm encoding);

Description

The OpenFileForWrite activity opens a 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 file shall be automatically locked to prevent simultaneous reading or writing.

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
FileWriteHandle Returns a file handle for the file in the specified path.

Properties

Name Data Type Class Default Cardinality Description
Append Boolean Term - [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.
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.FileWriteHandle FileWriteHandle1;

/// Flow

FileWriteHandle1 = File.OpenFileForWrite("file:///D:/abc.txt", false, @Encoding:UTF-8);

See also

CreateTempDirectory
GetFilePath
GetFilesFromDirectory
GetFileSize
IsDirectory
IsEndOfFileReached
IsFile
OpenFileForRead
ReadBytes
ReadFile
ReadLine