|
Class Reference
%Stream.FileBinary
|
|
![]() |
|||
Private Storage |
Stream class that stores binary data in files.
|
|
Properties | |||
---|---|---|---|
%Location | AtEnd | CanonicalFilename | Filename |
Id | LastModified | LineTerminator | ReadSize |
RemoveOnClose | Size | UseVMSVersion |
Subclasses |
---|
%Stream.FileCharacter |
|
|
Read only property that returns the canonical filename if the file is open and "" if the file is not open. On VMS this will include the file version number
The filename that this stream is currently using
For file streams the line will terminate on any of the characters set in the LineTerminator, it does not support multi-character line terminators because it uses the Cache file behavior which terminates on any of the characters. Updating this in the middle of a file on VMS will rewind the file to the beginning because of the way files work on VMS.
While reading this holds the file size
If true then remove the permanent file as well as any temp file when this object is closed
If true then on VMS only do not delete the persistent file before replacing it with the new version. This will cause the new version to be written with a new version number and so will keep the old file version present.
|
Checks to see if the object identified by the OID oid exists in the extent.Returns
%Boolean TRUE is it exists, FALSE if it does not.
Returns true (1) if a property of this instance has been modified, otherwise false (0). A TRUE result does not necessarily mean that any property has actually been changed. If %IsModified() returns false then the object has not been modified. There are some situations where we simply cannot efficiently detect a change in value. In these cases we will set the modified status of the property.
This is a Set accessor method for the%Location property.
Normalizes all of an object's property values by invoking the data type Normalize methods. Many data types may allow many different representations of the same value. Normalization converts a value to its cannonical, or normalized, form.
This method is somewhat similar to %IsModified but it also checks to see if swizzled references would cause the object to become modified should they be serialized. This works on the assumption that a reference to a persistent object will never be modified if the ID has already been assigned. For references to serial objects, a call to %ObjectModified indicates whether or not the serialized value is different. If the reference to a swizzled object is different from the initial object state then the $$$objModAll macro will already return true. Reference the Set code. Returns true (1) if this instance has been modified, otherwise false (0).
This method validates an object. The %Save method of a persistent class calls it before filing any objects in the database. The %ValidateObject method of a referencing object can call it. You can also call it explicitly at any time.
%ValidateObject does the following:
- It tests 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 object's %ValidateObject method for object-valued properties.
- If present, it will call a user-supplied
%OnValidateObject method.If any of these tests fail,
%ValidateObject immediately returns an error value. It is up to the caller of %ValidateObject to process the error value.Returns a
%Status value indicating success or failure.
This is a Get accessor method for theCanonicalFilename property.
Clear the contents of this Stream from permanent storage. This will remove the permanent stream storage and any temporary stream and initialise the stream to its initial state that it starts in, including removing all the stream attributes.Returns a
%Status value indicating success or failure.
Copies the contents of source into this Stream.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.
Return the current size of the file in bytes.
This is a Get accessor method for theFilename property.
This is a Set accessor method for theFilename property.
Flush any output in the stream not already saved.
Returns true if this is a "NULL" stream; that is, a stream which has never been written to and saved and has no stream attributes. This is used by the Caché ODBC server.
This is a Get accessor method for theLastModified property.
This is a Set accessor method for theLineTerminator property.
This method lets you connect a file stream to a file called filename without making a copy of it. If the file does not already exist it will still allow you to link to this file, and IsNull() will return true until you write to this file.The method as its name suggests creates a LINK to an EXISTING file. So this is a 'shared public' file, as it can be shared by several instances of a class, or even several classes. Using theDo object.Image.LinkToFile("\temp\image.jpg") Do object.%Save()CopyFrom method, on the contrary, creates a 'private' image, not sharable by other instances/classes, so these two methods are really different.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.
Move to the end of the stream so the nextWrite will be appended to the end. This allows you to read from a stream, then MoveToEnd() and append new data, where just calling Write after a read will clear the stream before writing new data.Returns a
%Status value indicating success or failure.
Write out len characters of the stream to the current device starting from the current position. This method is optimised for performance by the various sub classes. If len is omitted or set to -1 then it will write out the entire stream starting at the beginning.
Reads up to len characters from the current position in the stream. The current position is advanced by the number of characters read. Upon exit, len is set to the actual number of characters read. If a read occurs when the stream position is at the end of the stream, len will be set to -1 andRead will return a null string ("").You must call
Rewind if you want to read a stream from the beginning again. CallingRead afterWrite implicitly ends theWrite 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.
Read a line from the stream. Note that besides the normal ReadLine arguments this can also be passed a term which will return the termintor that completed the line if we read in a whole line.
Go back to the start of the stream.
Return the current size of the data stream.
Return true if this stream oid is a null stream and false if the stream is not null
Appends the string data to the stream and advances the current stream position by the number of characters in data.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.
Appends the string data along with a line terminator to the stream and advances the current stream position by the number of characters in data plus the line terminator.Returns a
%Status value indicating success or failure.