wxFFile
generated from ../src/mod_io/ffile.cpp
A wxFFile performs raw file I/O.
This is a very small class designed to minimize the overhead of using it -
in fact, there is hardly any overhead at all, but using it brings you
automatic error checking and hides differences between platforms.
It wraps inside it a FILE * handle used by standard C IO library (also known as stdio).
Remark :
A FILE* structure can't be used directly in JavaScript. That's why some methods are not
ported.
Constants
wxFileKind
| Name | Description |
|---|---|
| KIND_UNKNOWN | |
| KIND_DISK | |
| KIND_TERMINAL | |
| KIND_PIPE |
wxSeekMode
| Name | Description |
|---|---|
| FromCurrent | |
| FromStart | |
| FromEnd |
Constructor
wxFFile
wxFFile(name,
mode = r)
| Name | Type | Default | Description |
|---|---|---|---|
| name | String | Filename | |
| mode | String | r | The mode in which to open the file |
Creates a new wxFFile object
Properties
Methods
close
close() : Boolean
Closes the file.
flush
flush() : Boolean
Flushes the file.
open
open(Filename,
Mode = r) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Filename | String | Name of the file | |
| Mode | String | r | The mode in which to open the file |
Opens a file.
read
read(Count) : Buffer
| Name | Type | Default | Description |
|---|---|---|---|
| Count | Integer | The number of bytes to read. |
Reads the specified number of bytes.
readAll
readAll(encoding = UTF-8) : String
| Name | Type | Default | Description |
|---|---|---|---|
| encoding | String | UTF-8 | The encoding of the file. |
Reads all the data and return it in a String. Because most files are stored in UTF-8 or ASCII, the default of the encoding is UTF-8.
seek
seek(Offset,
Mode = wxFFile.FromStart) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Offset | Integer | Offset to seek to | |
| Mode | wxSeekMode | wxFFile.FromStart |
Seeks the offset. Returns the actual position or -1 on error.
seekEnd
seekEnd(Offset) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Offset | Integer | Offset to seek to. |
Moves the file pointer to the specified number of bytes before the end of the file. Returns true on success.
write
write(Buffer) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| Buffer | Buffer |
write(Str,
Encoding = UTF-8) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| Str | String | ||
| Encoding | String | UTF-8 |
Writes the string or buffer to the file. When you write a String you can specify an encoding. Because most files are still written as UTF-8 or ASCII, UTF-8 is the default. Returns the actual number of bytes written to the file when a buffer is used.

© 2002 - 2007 Franky Braem.