direct.stdpy.file

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.

Inheritance diagram

Inheritance diagram of direct.stdpy.file

class StreamIOWrapper(stream, needsVfsClose=False)[source]

Bases: IOBase

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)[source]
close(self)[source]
flush(self)[source]
read(self, size=-1)[source]
readable(self)[source]
readline(self, size=-1)[source]
seek(self, offset, whence=0)[source]
tell(self)[source]
writable(self)[source]
write(self, b)[source]
writelines(self, lines)[source]
execfile(path, globals=None, locals=None)[source]
exists(path)[source]
getmtime(path)[source]
getsize(path)[source]
isdir(path)[source]
isfile(path)[source]
lexists(path)[source]
listdir(path)[source]

Implements os.listdir over vfs.

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)[source]

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)[source]

Implements os.walk over vfs.

Note: we don’t support onerror or followlinks; errors are ignored and links are always followed.