Provides access to C <stdio> buffered file I/O functions.

The fileio module provides classes and functions for reading and writing files using the system's buffer I/O interfaces, as well as classes for listing the contents of directories.


_class BinaryFile(File)

Equivalent to File but using bytes instead of string str.




_class Directory(object)

Represents an opened file system directory.



Yields one iteration through the directory.



Closes the directory upon exit from a with block.

_for x in Directory:


Iterates over the contents of the directory.

Each iteration returns dict with two entries: "name" and "inode".


Close the directory.

Further reads can not be made after the directory has been closed.

_class File(object)

Interface to a buffered file stream.

_let x = File()


File objects can not be initialized using this constructor. Use the open() function instead.




Close the stream and flush any remaining buffered writes.


Flush unbuffered writes to the stream.

Read from the stream.

Reads up to bytes bytes from the stream. If bytes is -1 then reading will continue until the system returns end of file.


Read one line from the stream.


Read the entire stream and return a list of lines.


Write to the stream.

Writes the contents of data to the stream.



Open a file.

Opens path using the modestring mode. Supported modestring characters depend on the system implementation. If the last character of mode is 'b' a BinaryFile will be returned. If the file could not be opened, an IOError will be raised.


Open a directory for scanning.

Opens the directory at path and returns a Directory object. If path could not be opened or is not a directory, IOError will be raised.

Other Members

let stderr = File

let stdin = File

let stdout = File