back to io 

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

Name Type Description
eof read only Boolean True when end of file is reached. When the file is not open, undefined is returned.
kind read only Integer Returns the type of the file
length read only Integer Returns the length of the file. When the file is not open, undefined is returned.
opened read only Boolean True when the file is open.
tell read only Integer Returns the current position or -1 (invalid offset). When the file is not open, undefined is returned.

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.



SourceForge.net Logo Support This Project

Table of Contents

Constructor

wxFFile

Properties

eof
kind
length
opened
tell

Methods

close
flush
open
read
readAll
seek
seekEnd
write


Design downloaded from Zeroweb.org: Free website templates, layouts, and tools.