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)
_class Directory(object)
Represents an opened file system directory.
_Directory()
Yields one iteration through the directory.
_Directory.__enter__()
_Directory.__exit__()
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".
_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.__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.