fileio

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.

Classes

_class BinaryFile(File)

Equivalent to File but using bytes instead of string str.

_BinaryFile.read()

_BinaryFile.readline()

_BinaryFile.readlines()

_BinaryFile.write()

_class Directory(object)

Represents an opened file system directory.

_Directory()

Directory.__call__()

Yields one iteration through the directory.

_Directory.__enter__()

_Directory.__exit__()

Closes the directory upon exit from a with block.

_for x in Directory:

Directory.__iter__()

Iterates over the contents of the directory.

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

_Directory.close()

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.__init__()

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

_File.__enter__()

_File.__exit__()

_File.close()

Close the stream and flush any remaining buffered writes.

_File.flush()

Flush unbuffered writes to the stream.

_File.read(bytes=-1)

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.

_File.readline()

Read one line from the stream.

_File.readlines()

Read the entire stream and return a list of lines.

_File.write(data)

Write to the stream.

Writes the contents of data to the stream.

Functions

_open(path,mode="r")

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.

_opendir(path)

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