from direct.stdpy.file import StreamIOWrapper, execfile, exists, getmtime, getsize, isdir, isfile, lexists, listdir, open, walk
This module reimplements Python’s file I/O mechanisms using Panda constructs. This enables Python to interface more easily with Panda’s virtual file system, and it also better-supports Panda’s SIMPLE_THREADS model, by avoiding blocking all threads while waiting for I/O to complete.
- class StreamIOWrapper(stream, needsVfsClose=False)¶
This is a file-like object that wraps around a C++ istream and/or ostream object. It only deals with binary data; to work with text I/O, create an io.TextIOWrapper object around this, or use the open() function that is also provided with this module.
- __init__(self, stream, needsVfsClose=False)¶
- read(self, size=- 1)¶
- readline(self, size=- 1)¶
- seek(self, offset, whence=0)¶
- write(self, b)¶
- writelines(self, lines)¶
- execfile(path, globals=None, locals=None)¶
Implements os.listdir over vfs.
- open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True)¶
This function emulates the built-in Python open() function, additionally providing support for Panda’s virtual file system. It takes the same arguments as Python’s built-in open() function.
- walk(top, topdown=True, onerror=None, followlinks=True)¶
Implements os.walk over vfs.
Note: we don’t support onerror or followlinks; errors are ignored and links are always followed.