This code does not rely on an instance of ShowBase (base), and provides a fix (joining more than 2 parts of a path) to direct.stdpy.file.join.
Honestly though, direct.stdpy.file.join just sticks '/' between the parts, so '/'.join(*paths) would do the same thing, but faster (maybe that should be put in direct.stdpy.file.join).
os.path.join is much smarter, so you have to be carful when switching over to this join. Mainly, os.path.join deals with trailing /s at the end where this approach does not.
This code works for me, though my use case is not too strict. I've tried it on my macs, and inside a p3d file on Windows. I'll admit its not feature complete, or very tidy, but its exposes some hard to find panda internals in an easy to use way. Stick it in a module in your project and use it instead of the equivalent os and os.path methods and it will still work after being packed into a p3d file.
- Code: Select all
from direct.showbase.AppRunnerGlobal import appRunner
from direct.stdpy import file
from panda3d.core import Filename
""" Implements os.path.isdir over vfs. """
""" Implements os.path.exists over vfs. """