Home Index classes Index static functions Index enumerations Index structure types

{File_stream}


CLASS {File_stream} , BYTES, DESTRUCTORS, NATIVE, TESTED(76) :


Class to work with files via streams.


IMPORT : {Stream} , {File_path} .

BASE CLASS {Stream} .



--------------------------------------------------------- 'fields for read'

INT Handle|_of_file_stream_object , READ

A file opened descriptor.


STR Path|_of_file , READ , INIT

Path of the file opened.


{mode_file} Mode|_file_opened , READ , INIT

A mode used to open the file.


 

ENUMERATION {mode_file|_stream} :

        'READ|_FILE' ,

        'WRITE|_FILE' ,

        'READ_WRITE' ,

        'READ_ANYWAY|_even_if_file_already_opened_in_another_process' .


The enumeration of possible modes to open a file.


FUNCTION Read_file_stream (
     
STR Path|_to_file ) ==> {File_stream} , NEW


Creating a stream to read a file.


FUNCTION Anyway_read_file_stream (
     
STR Path|_to_file ) ==> {File_stream} , NEW



FUNCTION Write_file_stream (
     
STR Path|_to_file ,
     
BOOL Can_read ) ==> {File_stream} , NEW


Creating a stream to write a file. In case when Can_read = TRUE, an existing file is opened not truncated, but with the position set to 0, and it is possible to move current position to any other position and read / write bytes there.


---------------------------------------------------------- 'size, position'


OVERRIDE Size ==> {Long_int}.{long}


The size of the stream is the size of the file opened.


OVERRIDE Position ==> {long}


The position in the stream is the position in the file opened.


OVERRIDE Set_pos (
     
{long} New|_position ,
     
{Stream}.{disp} Disp|osition_from )


Moving current position in the file.


OVERRIDE Ended ==> BOOL


TRUE, if the current position is out of the file.


----------------------------------------------------------------- 'closing'


OVERRIDE Close , REPLACE


Closing the file and the stream.


OVERRIDE Closed ==> BOOL


TRUE, if the file is already closed. It is not possible to do any operations with a closed stream.


-------------------------------------------------------- 'read/write bytes'


OVERRIDE Load_bytes (
     
BYTE Dest|ination [] ,
     
INT Count|_bytes_read ) ==> BOOL


Implementing Load_bytes operation for a file stream. Maximum Count bytes are loaded into the buffer Dest (which first is cleared anyway). TRUE is returned if any bytes are loaded. Usually amount of bytes loaded can be smaller then the Count only if the position was near to the end of the file. But actually other reasons are possible.


OVERRIDE Read_bytes ( BYTE Dest|ination [*] ) ==> INT


Implementing Read_bytes operation for a file stream, reading bytes to the fixed array Dest[] and returning amount of bytes which were read.


OVERRIDE Save_bytes ( BYTE Source|_bytes [*] ) ==> INT


Implementing Save_bytes operation for a file stream, writing entire fixed array Source[] and returning amount of bytes written.

END