file/ file.bi | |
License | Copyright © 2009, FreeBASIC Extended Library Development Group |
ext | |
File | Manages a connection to a disk file. |
Enumerations | |
ACCESS_TYPE | Used to specify the access to use when opening a file. |
Functions and Properties | |
constructor | Sets the file to open and its access level. |
default constructor | Constructs an invalid File object. |
open | Used with the default constructor to open a file. |
open | Opens the file specified to the constructor. |
close | Closes access to a disk file. |
handle | Used to retrieve the handle of the open file for use in input and write statements. |
lof | Retrieves the length of the currently open file in bytes. |
loc | Retrieves the current position in the file. |
eof | Tells whether or not the end of the file has been reached. |
seek | Seeks to a position in the file. |
seek | Returns the position in the file the next read or write will happen. |
Overloaded print routine that will print one of any built-in datatype. | |
Overloaded print routine that will print an array of any built-in datatype. | |
get | Gets any number of a datatype from the open file, overloaded for all built-in types. |
put | Puts any number of a datatype to the open file, overloaded for all built-in types. |
linput | Line Input function. |
LastError | Retrieves the error number of the last error, only set by open |
Examples | |
Simple File class example |
Copyright © 2009, FreeBASIC Extended Library Development Group
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License
Manages a connection to a disk file.
This class is Threadsafe.
Enumerations | |
ACCESS_TYPE | Used to specify the access to use when opening a file. |
Functions and Properties | |
constructor | Sets the file to open and its access level. |
default constructor | Constructs an invalid File object. |
open | Used with the default constructor to open a file. |
open | Opens the file specified to the constructor. |
close | Closes access to a disk file. |
handle | Used to retrieve the handle of the open file for use in input and write statements. |
lof | Retrieves the length of the currently open file in bytes. |
loc | Retrieves the current position in the file. |
eof | Tells whether or not the end of the file has been reached. |
seek | Seeks to a position in the file. |
seek | Returns the position in the file the next read or write will happen. |
Overloaded print routine that will print one of any built-in datatype. | |
Overloaded print routine that will print an array of any built-in datatype. | |
get | Gets any number of a datatype from the open file, overloaded for all built-in types. |
put | Puts any number of a datatype to the open file, overloaded for all built-in types. |
linput | Line Input function. |
LastError | Retrieves the error number of the last error, only set by open |
Examples | |
Simple File class example |
declare constructor ( byref filename as const string, byval acc as ACCESS_TYPE = R )
Sets the file to open and its access level.
filename | the file to open. |
acc | one of ACCESS_TYPE |
Constructs an invalid File object. Use the open function to make this a valid File object.
declare function open( byref filename as const string, byval acc as ACCESS_TYPE = R ) as ext.bool
Used with the default constructor to open a file.
filename | the file to open. |
acc | one of ACCESS_TYPE |
ext.false on success, ext.true on failure.
declare sub get( byval filepos as longint = -1, byref data_ as fbext_TypeName(T_), byval amount as integer = 1 )
Gets any number of a datatype from the open file, overloaded for all built-in types.
filepos | optional file position to retrieve the data from, defaults to the current file postition. |
data_ | the variable to retrieve the data into. |
amount | optional amount of data to retrieve, defaults to 1. |
declare sub put( byval filepos as longint = -1, byref data_ as fbext_TypeName(T_), byval amount as integer = 1 )
Puts any number of a datatype to the open file, overloaded for all built-in types.
filepos | optional file position to place the data at, defaults to the current file postition. |
data_ | the data to place in the file. |
amount | optional amount of data to place, defaults to 1. |
declare property LastError () as integer
Retrieves the error number of the last error, only set by open
integer value of the error code.
Sets the file to open and its access level.
declare constructor ( byref filename as const string, byval acc as ACCESS_TYPE = R )
Used with the default constructor to open a file.
declare function open( byref filename as const string, byval acc as ACCESS_TYPE = R ) as ext.bool
Closes access to a disk file.
declare sub close()
Used to retrieve the handle of the open file for use in input and write statements.
declare property handle() as integer
Retrieves the length of the currently open file in bytes.
declare function lof() as longint
Retrieves the current position in the file.
declare function loc() as longint
Tells whether or not the end of the file has been reached.
declare function eof() as ext.bool
Seeks to a position in the file.
declare property seek( byval poz as longint )
Overloaded print routine that will print one of any built-in datatype.
declare sub print ( byref data_ as fbext_TypeName(T_) )
Gets any number of a datatype from the open file, overloaded for all built-in types.
declare sub get( byval filepos as longint = -1, byref data_ as fbext_TypeName(T_), byval amount as integer = 1 )
Puts any number of a datatype to the open file, overloaded for all built-in types.
declare sub put( byval filepos as longint = -1, byref data_ as fbext_TypeName(T_), byval amount as integer = 1 )
Line Input function.
declare function linput () as string
Retrieves the error number of the last error, only set by open
declare property LastError () as integer