%Stream.FileBinary
stream class %Stream.FileBinary extends %Stream.Object
For information on this class, see Working with Streams.
Stream class that stores binary data in files. For example, the following code opens a file binary stream, points it at a particular file on the filesystem, and then reads it in chunks of 32,000 bytes:Set stream=##class(%Stream.FileBinary).%New() Set sc=stream.LinkToFile("c:\myfile.txt") While 'stream.AtEnd { Set line=stream.Read() ; Process the chunk here }
Property Inventory
Method Inventory
- %Exists()
- %IsModified()
- %IsNull()
- %LocationSet()
- %NormalizeObject()
- %ObjectIsNull()
- %ObjectModified()
- %ValidateObject()
- CanonicalFilenameGet()
- Clear()
- CopyFrom()
- DefaultStreamDir()
- FileBinarySize()
- FilenameGet()
- FilenameSet()
- Flush()
- IdSet()
- LastModifiedGet()
- LineTerminatorSet()
- LinkToFile()
- MoveToEnd()
- NewFileName()
- OutputToDevice()
- Read()
- ReadLine()
- ReadLineIntoStream()
- Rewind()
- SizeGet()
- Write()
- WriteLine()
Parameters
Properties
If you set this property to update the file we will write to/read from this operation can fail if for example the directory specified does not exist. To detect this failure either check the %Status return code of the FilenameSet() or if using 'Set stream.Filename=newname' then check %objlasterror after the call to see if it reported an error.
Also for %FileCharacterStream even if you set this when you call WriteLine() as the file was opened in 'S' mode it will normalize the line terminator as the data is being written, so for example if you set LineTerminator to $char(13,10) on Unix systems when you call WriteLine() it will only write $char(10) to the file.
Methods
Returns %Boolean TRUE is it exists, FALSE if it does not.
This method validates an object.
The %Save() method of a persistent class calls this method before filing any objects in the database. The %ValidateObject() of a referencing object can call it. You can also call it explicitly at any time.
%ValidateObject() does the following:
- If present, it will call a user-supplied %OnValidateObject() method.
- It checks if any required property values are missing.
- If the PROPERTYVALIDATION class parameter is set to ValidateOnSave, it validates each non-null property value by calling the property method IsValid on each literal property and the %ValidateObject method for each object-valued embedded object property (properties whose type extend %SerialObject).
- If checkserial is 1, it forces the checking of any embedded object properties by calling their %ValidateObject method after swizzling this property.
- If checkserial is 2, it forces the checking of any collections of serial types by iterating over those collections and calling their %ValidateObject() method after swizzling this property, in addition to the validation that occurs when checkserial is 1.
%ValidateObject() returns a %Status indicating success or error. It is up to the caller to process the error value.
%ValidateObject() does not validate object-valued reference properties (properties whose type extends %Persistent) due to the possibility of circular dependencies between objects. The %Save() method of a persistent class automatically detects and handles circular references between objects. If you require the validation of reference properties, you can override this method in a subclass or call %Save() directly.
Returns a %Status value indicating success or failure.
For example, you can copy oldstream into a new stream:
Set newstream=##class(%GlobalCharacterStream).%New() Do newstream.CopyFrom(oldstream)
Returns a %Status value indicating success or failure.
Do object.Image.LinkToFile("\temp\image.jpg") Do object.%Save()
The problems with shared public images are that several instances are all allowed to update and even delete the image, causing problems for other instances.
For example, if dog #2 has image 'test.gif', I can also assign that image to dog #5 or even person #24 If I change the image for dog #5, then the image is changed in place to another image, thus upsetting dog#2 and person#24. If I delete dog#5, the image is also deleted and thus dog#2 and person#24 are changed.
Also note that if there is currently some temporary data in the old stream when the LinkToFile() is called this temporary data will be removed before the stream is linked to this filename.
Returns a %Status value indicating success or failure.
You must call Rewind() if you want to read a stream from the beginning again. Calling Read() after Write() implicitly ends the Write() operation and rewinds to the start of the stream.
Returns a string up to len characters long. The byref argument sc will return a %Status if any error occurred during the read.
Note that a write operation immediately following a read or rewind will clear out the existing data in the stream.
Returns a %Status value indicating success or failure.
Returns a %Status value indicating success or failure.
Inherited Members
Inherited Properties
Inherited Methods
- %AddToSaveSet()
- %CheckUnique()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %Delete()
- %DeleteExtent()
- %DeleteId()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %ExistsId()
- %Extends()
- %GetParameter()
- %GetSwizzleObject()
- %Id()
- %IsA()
- %KillExtent()
- %LOBPrefetch()
- %LockStream()
- %New()
- %ObjectSize()
- %Oid()
- %Open()
- %OpenId()
- %OriginalNamespace()
- %PackageName()
- %ReleaseLock()
- %Reload()
- %RemoveFromSaveSet()
- %RollBack()
- %Save()
- %SerializeObject()
- %SetModified()
- %UnlockStream()
- CopyFromAndSave()
- FindAt()
- GetStreamId()
- InputFromDevice()
- IsCharacter()
- IsNull()
- MoveTo()
- OutputToDeviceAt()
- ReadSQL()
- SerializeToSyncSet()
- StreamOIDIsNull()
- SyncStreamIn()