Class Reference
IRIS for UNIX 2024.1.2
InterSystems: The power behind what matters   
Documentation  Search
  [USER] >  [%IO] >  [FileStream]
Private  Storage   

class %IO.FileStream extends %IO.DeviceStream, %IO.IParts.CharacterSeekableIO

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
10 7 16


Summary

Properties
%Mode %ReadLineMode AtEnd BuildCharPosMap
CharEncoding DefaultFlushOnWrite ExternalBytePosition ExternalByteSize
IsCharacter IsOpen IsSingleByte IsTemp
LastModified LineTerminator Name Position
Size TranslationTable

Methods
%AddToSaveSet %ClassIsLatestVersion %ClassName %ConstructClone
%DispatchClassMethod %DispatchGetModified %DispatchGetProperty %DispatchMethod
%DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty %Extends
%GetParameter %IsA %IsModified %New
%NormalizeObject %ObjectModified %OriginalNamespace %PackageName
%RemoveFromSaveSet %SerializeObject %SetModified %ValidateObject
Attach AttachNew CharEncodingSet Clear
Close CopyFrom CopyReplace CopyReplaceArray
DefaultFlushOnWriteGet ExternalByteSeek ExternalByteSizeGet ExternalByteTruncateAt
Find Flush GetCharEncodingTable GetDeviceLineTerminator
GetDeviceTranslationTable GetLocaleDefaultTable GetTableCharEncoding InputFromDevice
IsCharacterGet IsLocaleUnicode IsTableSingleByte LastModifiedGet
NewTempFilename Open OutputToDevice Read
ReadLine ReadUntil ReadUntilArray Rewind
Seek SetCharEncodingTable SetDeviceLineTerminator SetDeviceTranslationTable
SetTranslationTable SizeGet TranslationTableSet TruncateAt
Write WriteLine


Parameters

• parameter DEFTEMPFILEEXT = "iostream";
• parameter READ = "R";
• final parameter RWREADCHANGED = 2;
• final parameter RWREADNODATA = 0;
• final parameter RWREADNOTCHANGED = 1;
• final parameter RWWRITE = 3;
• parameter WRITE = "W";
• parameter WRITEAPPEND = "A";
• parameter WRITENEWIFABSENT = "E";
• parameter WRITENEWOVER = "N";

Properties

• property %Mode as %String(TRUNCATE=1) [ ReadOnly ];
• property %ReadLineMode as %Boolean [ ReadOnly ];
• property BuildCharPosMap as %Boolean [ InitialExpression = 1 ];
Flag to control whether the stream object should maintain the charposmap map between character positions and external byte positions when the file is opened using a multibyte character encoding. This flag is ignored when the character set only contains single-bye characters. The flag is initialized to 0 when a file is not opened with the READ flag, but can always be modified by the user after Open() has been called.
• property IsTemp as %Boolean;
Flag to control whether this file is deleted automatically when the file object instance is killed or goes out of scope. The default is 0, and the file is NOT automatically deleted.
• property LastModified as %TimeStamp [ Calculated ];

Methods

• method Close(Output pSC As %Status) as %Boolean
Close the current stream
• method ExternalByteSeek(pBytePos As %Integer, Output pSC As %Status) as %Boolean
• method ExternalByteSizeGet() as %Integer
This is a Get accessor method for the ExternalByteSize property.
• method ExternalByteTruncateAt(pBytePos As %Integer, Output pSC As %Status) as %Boolean
• method Flush(Output pSC As %Status)
Ensure that any data already written to the stream buffer is sent to the stream.

In addition a reopen of the file takes place.

Note: The Flush method does not ensure that data actually gets flushed to disk. Using the traditional COS "W *-3" to a device ensures that this occurs.

• method LastModifiedGet() as %TimeStamp
This is a Get accessor method for the LastModified property.
• classmethod NewTempFilename(tExt As %String = "", pUseTempDir As %Boolean = 0, pDirectory As %String = "") as %String
Create a new, unused filename. By default, the returned filename will have no directory component and will have the default file extension specified in DEFTEMPFILEEXT. If tExt is specified, this will be used as the file extension. If pUseTempDir is true, then the filename will include the current temporary directory for the namespace in which the method is called. If pDirectory is specified, the supplied directory name will be used irrespective of the value of pUseTempDir.
• method Open(pName As %String = "", pMode As %String = "R", ByRef pTimeout As %Numeric = 0, pCharEncoding As %String = "Native", Output pSC As %Status) as %Boolean
• method Read(pMaxReadLen As %Integer, ByRef pTimeout As %Numeric = -1, Output pSC As %Status) as %String
Read until pMaxReadLen chars are gotten or pTimeout expires On return, if pTimeout is unchanged it means the full timeout period expired. If the timeout period expired and the returned string is shorter than pMaxReadLen, then AtEnd will be 1.
• method ReadLine(pMaxReadLen As %Integer, ByRef pTimeout As %Numeric = -1, Output pSC As %Status, ByRef pLineTerminator As %String = ..LineTerminator) as %String
Read until pMaxReadLen chars are gotten, pTimeout expires, or a LineTerminator character is found. On return, if pTimeout=0 it means no timeout occurred. If pTimeout=0 and the returned string contains the full pMaxReadLen characters, it means no LineTerminator was encountered yet, even if the following character would be a LineTerminator. If pTimeout=0 and the returned string is shorter than pMaxReadLen, then either a LineTerminator or the End Of Stream (AtEnd = 1) was encountered. If pLineTerminator is defined, then the line is read until one of the given characters is encountered. On return, pLineTerminator contains the encountered character(s) if any.
• method Seek(pPosition As %Integer = 1, Output pSC As %Status) as %Boolean
• method SizeGet() as %Integer
Return the current character size of the data stream.
• method TruncateAt(pPosition As %Integer, Output pSC As %Status) as %Boolean
• method Write(pData As %String = "", pFlush As %Boolean, Output pSC As %Status)
Write pData to the stream buffer. If pFlush is True, ensure that the data are actually sent to the stream.


Copyright (c) 2025 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.