Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Clib_file Source Code
 previous   up   next 

Types
clib_file
File type realized with FILE * files from the C runtime library.

clib_file

const type: clib_file

File type realized with FILE * files from the C runtime library. The type clib_file is not accessable via the file interface. The type external_file, which implements the file interface is based on a clib_file. Access to operating system files should always be done via the file interface and files of the type external_file.


Constant Summary
clib_file
CLIB_NULL_FILE
NULL file of the C runtime library.

Operator Summary
boolean
(ref clib_file: file1) = (ref clib_file: file2)
Check if two files are equal.
boolean
(ref clib_file: file1) <> (ref clib_file: file2)
Check if two files are not equal.

Function Summary
clib_file
openClibFile (in string: path, in string: mode)
Opens a clib_file with the specified path and mode.
void
close (ref clib_file: aFile)
Close a clib_file.
boolean
eof (ref clib_file: inFile)
Determine the end-of-file indicator.
boolean
hasNext (ref clib_file: inFile)
Determine if at least one character can be read successfully.
void
flush (ref clib_file: outFile)
Forces that all buffered data of outFile is sent to its destination.
char
getc (ref clib_file: inFile)
Read a character from a clib_file.
string
gets (ref clib_file: inFile, ref integer: maxLength)
Read a string with a maximum length from a clib_file.
string
word_read (ref clib_file: inFile, inout char: terminationChar)
Read a word from a clib_file.
string
line_read (ref clib_file: inFile, inout char: terminationChar)
Read a line from a clib_file.
void
write (ref clib_file: outFile, in string: stri)
Write a string to a clib_file.
integer
length (ref clib_file: aFile)
Obtain the length of a clib_file.
void
seek (ref clib_file: aFile, ref integer: position)
Set the current file position.
integer
tell (ref clib_file: aFile)
Obtain the current file position.

Constant Detail

CLIB_NULL_FILE

const clib_file: CLIB_NULL_FILE

NULL file of the C runtime library. This value is returned by openClibFile and other functions, when no clib_file could be opened. Reading from or writing to a CLIB_NULL_FILE raises an exception.


Operator Detail

=

const func boolean: (ref clib_file: file1) = (ref clib_file: file2)

Check if two files are equal.

Returns:
TRUE if the two files are equal, FALSE otherwise.

<>

const func boolean: (ref clib_file: file1) <> (ref clib_file: file2)

Check if two files are not equal.

Returns:
FALSE if both files are equal, TRUE otherwise.

Function Detail

openClibFile

const func clib_file: openClibFile (in string: path, in string: mode)

Opens a clib_file with the specified path and mode. There are text modes and binary modes:

  • Binary modes:
    • "r" Open file for reading.
    • "w" Truncate to zero length or create file for writing.
    • "a" Append; open or create file for writing at end-of-file.
    • "r+" Open file for update (reading and writing).
    • "w+" Truncate to zero length or create file for update.
    • "a+" Append; open or create file for update, writing at end-of-file.
  • Text modes:
    • "rt" Open file for reading.
    • "wt" Truncate to zero length or create file for writing.
    • "at" Append; open or create file for writing at end-of-file.
    • "rt+" Open file for update (reading and writing).
    • "wt+" Truncate to zero length or create file for update.
    • "at+" Append; open or create file for update, writing at end-of-file.

Note that this modes differ from the ones used by the C function fopen().

Parameters:
path - Path of the file to be opened. The path must use the standard path representation.
mode - Mode of the file to be opened.
Returns:
the file opened, or STD_NULL if it could not be opened or when path refers to a directory.
Raises:
MEMORY_ERROR - Not enough memory to convert the path to the system path type.
RANGE_ERROR - The mode is not one of the allowed values or path does not use the standard path representation or path cannot be converted to the system path type.

close

const proc: close (ref clib_file: aFile)

Close a clib_file.

Raises:
FILE_ERROR - A system function returns an error.

eof

const func boolean: eof (ref clib_file: inFile)

Determine the end-of-file indicator. The end-of-file indicator is set when at least one request to read from the file failed.

Returns:
TRUE if the end-of-file indicator is set, FALSE otherwise.

hasNext

const func boolean: hasNext (ref clib_file: inFile)

Determine if at least one character can be read successfully. This function allows a file to be handled like an iterator.

Returns:
FALSE if getc would return EOF, TRUE otherwise.

flush

const proc: flush (ref clib_file: outFile)

Forces that all buffered data of outFile is sent to its destination. This causes data to be sent to the file system of the OS.


getc

const func char: getc (ref clib_file: inFile)

Read a character from a clib_file.

Returns:
the character read, or EOF at the end of the file.

gets

const func string: gets (ref clib_file: inFile, ref integer: maxLength)

Read a string with a maximum length from a clib_file.

Returns:
the string read.
Raises:
RANGE_ERROR - The length is negative.
MEMORY_ERROR - Not enough memory to represent the result.
FILE_ERROR - A system function returns an error.

word_read

const func string: word_read (ref clib_file: inFile, inout char: terminationChar)

Read a word from a clib_file. Before reading the word it skips spaces and tabs. The function accepts words ending with " ", "\t", "\n", "\r\n" or EOF. The word ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left terminationChar contains ' ', '\t', '\n' or EOF.

Returns:
the word read.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.
FILE_ERROR - A system function returns an error.

line_read

const func string: line_read (ref clib_file: inFile, inout char: terminationChar)

Read a line from a clib_file. The function accepts lines ending with "\n", "\r\n" or EOF. The line ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left terminationChar contains '\n' or EOF.

Returns:
the line read.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.
FILE_ERROR - A system function returns an error.

write

const proc: write (ref clib_file: outFile, in string: stri)

Write a string to a clib_file.

Raises:
FILE_ERROR - A system function returns an error.
RANGE_ERROR - The string contains a character that does not fit into a byte.

length

const func integer: length (ref clib_file: aFile)

Obtain the length of a clib_file. The file length is measured in bytes.

Returns:
the size of the given file.
Raises:
RANGE_ERROR - The file length does not fit into an integer value.
FILE_ERROR - A system function returns an error or the file length reported by the system is negative.

seek

const proc: seek (ref clib_file: aFile, ref integer: position)

Set the current file position. The file position is measured in bytes from the start of the file. The first byte in the file has the position 1.

Raises:
RANGE_ERROR - The file position is negative or zero or the file position is not representable in the system file position type.
FILE_ERROR - A system function returns an error.

tell

const func integer: tell (ref clib_file: aFile)

Obtain the current file position. The file position is measured in bytes from the start of the file. The first byte in the file has the position 1.

Returns:
the current file position.
Raises:
RANGE_ERROR - The file position does not fit into an integer value.
FILE_ERROR - A system function returns an error or the file position reported by the system is negative.


 previous   up   next