The File Stream class provides I/O to a file system. In this documentation, the term directory is synonymous with "folder" in Windows.
All the functions provided in the Abstract Stream class can be used, and these additional functions:
Enum OpenModes Inherits Modes {
Overwrite = 256,
Append = 512 | Output,
};
Function Open (FileName: String @ "For" Mode: OpenModes);
This function attempts to open a file. If the open fails, an exception is thrown.
FileName --> the drive, path and filename of the file to open. If the drive is omitted on DOS/Windows systems, the current drive is assumed. If no path is provided, or if a relative path is given, the current directory for the thread is used as a base. Slashes and backslashes (/, \) are recognized as path separators on all implementations.
Mode: Mode in which to open the file. Multiple modes can be combined using the bitwise OR operator (|). The modes are as follows:
Note: On some systems, the file may be opened with more capabilities than requested.
The ReadPos and WritePos flags have no effect when opening files. Any file that is opened for Input will be able to retrieve the read pointer; and file that is opened for output will be able to retrieve the write pointer.
Function Close () Returns Boolean;
This function closes the currently opened file. True is returned on success, False on failure. The function can fail only if no file is open.
Function Destructor ();
This function closes the file if it is open.
The Memory Stream class allows data serialization to a block of memory. Uses of this class include data transfer between processes, or through the clipboard.
Function Create (Preallocate: Integer(0); GrowBy: Integer(64));
This function creates a block of memory for reading or writing and attaches itself to it. Preallocate specifies the amount of memory to allocate initially, while GrowBy specifies the granularity by which to increase the size of the block(s) containing the memory file. If the memory allocation fails, a ??? exception will be thrown. If the object is already attached to a block of memory, ??? exception is thrown.
Function Attach (ToRead: @; Size: Integer);
Associates the Memory File object with an existing block of memory, the size of which is specified by Size (in bytes).
If the Memory File is already attached to a memory block, a ??? exception will be thrown.
The Memory File object cannot write past the end of the block because it cannot reallocate the block (since it does not own the memory or know anything about it.) Attempting to write past the end of an attached block will cause a ??? exception to be thrown.
Function Close() Returns Boolean;
This function closes the memory file. If the file was created with Create, the memory block is freed; otherwise the object just "forgets about" the memory block with which it is associated. If the file is closed already, the function returns False; otherwise it returns True.
| Table of Contents | Qwertie's Site/Mirror |