mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
true_file_io
This commit is contained in:
parent
91f365e629
commit
02960fbddf
@ -86,6 +86,7 @@ class AppRunner(DirectObject):
|
|||||||
self.guiApp = False
|
self.guiApp = False
|
||||||
self.interactiveConsole = False
|
self.interactiveConsole = False
|
||||||
self.initialAppImport = False
|
self.initialAppImport = False
|
||||||
|
self.trueFileIO = False
|
||||||
|
|
||||||
self.sessionId = 0
|
self.sessionId = 0
|
||||||
self.packedAppEnvironmentInitialized = False
|
self.packedAppEnvironmentInitialized = False
|
||||||
@ -456,13 +457,21 @@ class AppRunner(DirectObject):
|
|||||||
# Put our root directory on the model-path, too.
|
# Put our root directory on the model-path, too.
|
||||||
getModelPath().appendDirectory(self.multifileRoot)
|
getModelPath().appendDirectory(self.multifileRoot)
|
||||||
|
|
||||||
# Replace the builtin open and file symbols so user code will get
|
if not self.trueFileIO:
|
||||||
# our versions by default, which can open and read files out of
|
# Replace the builtin open and file symbols so user code will get
|
||||||
# the multifile.
|
# our versions by default, which can open and read files out of
|
||||||
__builtin__.file = file.file
|
# the multifile.
|
||||||
__builtin__.open = file.open
|
__builtin__.file = file.file
|
||||||
os.listdir = file.listdir
|
__builtin__.open = file.open
|
||||||
os.walk = file.walk
|
os.listdir = file.listdir
|
||||||
|
os.walk = file.walk
|
||||||
|
os.path.isfile = file.isfile
|
||||||
|
os.path.isdir = file.isdir
|
||||||
|
os.path.exists = file.exists
|
||||||
|
os.path.lexists = file.lexists
|
||||||
|
os.path.getmtime = file.getmtime
|
||||||
|
os.path.getsize = file.getsize
|
||||||
|
sys.modules['glob'] = glob
|
||||||
|
|
||||||
def __startIfReady(self):
|
def __startIfReady(self):
|
||||||
""" Called internally to start the application. """
|
""" Called internally to start the application. """
|
||||||
@ -666,6 +675,10 @@ class AppRunner(DirectObject):
|
|||||||
if guiApp:
|
if guiApp:
|
||||||
self.guiApp = int(guiApp)
|
self.guiApp = int(guiApp)
|
||||||
|
|
||||||
|
trueFileIO = self.p3dConfig.Attribute('true_file_io')
|
||||||
|
if trueFileIO:
|
||||||
|
self.trueFileIO = int(trueFileIO)
|
||||||
|
|
||||||
# The interactiveConsole flag can only be set true if the
|
# The interactiveConsole flag can only be set true if the
|
||||||
# application has allow_python_dev set.
|
# application has allow_python_dev set.
|
||||||
if not self.allowPythonDev and interactiveConsole:
|
if not self.allowPythonDev and interactiveConsole:
|
||||||
@ -957,20 +970,6 @@ def dummyAppRunner(tokens = [], argv = None):
|
|||||||
vfs.mount(cwd, appRunner.multifileRoot, vfs.MFReadOnly)
|
vfs.mount(cwd, appRunner.multifileRoot, vfs.MFReadOnly)
|
||||||
|
|
||||||
appRunner.initPackedAppEnvironment()
|
appRunner.initPackedAppEnvironment()
|
||||||
|
|
||||||
# Replace some of the standard Python I/O functions with the Panda
|
|
||||||
# variants that are specially crafted to respect the vfs.
|
|
||||||
__builtin__.file = file.file
|
|
||||||
__builtin__.open = file.open
|
|
||||||
os.listdir = file.listdir
|
|
||||||
os.walk = file.walk
|
|
||||||
os.path.isfile = file.isfile
|
|
||||||
os.path.isdir = file.isdir
|
|
||||||
os.path.exists = file.exists
|
|
||||||
os.path.lexists = file.lexists
|
|
||||||
os.path.getmtime = file.getmtime
|
|
||||||
os.path.getsize = file.getsize
|
|
||||||
sys.modules['glob'] = glob
|
|
||||||
|
|
||||||
return appRunner
|
return appRunner
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user