The Virtual File System

General file reading in Panda is handled by the Virtual File System.

Although it presents the files and directories that it provides access to as a single, unbroken file system, it can in fact include files from multiple sources (such as Multifiles) in the hierarchy, regardless of the underlying structure.

This has the advantage of allowing one to access files and directories without worrying overmuch about where they actually reside, and even access Multifile archives as a directory hierarchy.

Python Interface

Panda3D offers a replacement for the Python file module that supports the virtual file system. You can find it in direct.stdpy.file. The interface is exactly the same as Python’s, so it’s safe to put this import above all the files where you want to use the open() function:

from direct.stdpy.file import *

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.

Besides the open() call, this module also contains replacements for various other functions provided by the Python os and os.path modules. See the API reference page for a full listing.

Note

This section is incomplete.