mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
Add version of execfile() that uses the VFS
This commit is contained in:
parent
2414bcd787
commit
350b2aaf3c
@ -702,6 +702,7 @@ class AppRunner(DirectObject):
|
||||
# the multifile.
|
||||
__builtin__.file = file.file
|
||||
__builtin__.open = file.open
|
||||
__builtin__.execfile = file.execfile
|
||||
os.listdir = file.listdir
|
||||
os.walk = file.walk
|
||||
os.path.join = file.join
|
||||
|
@ -7,6 +7,7 @@ for I/O to complete. """
|
||||
__all__ = [
|
||||
'file', 'open', 'listdir', 'walk', 'join',
|
||||
'isfile', 'isdir', 'exists', 'lexists', 'getmtime', 'getsize',
|
||||
'execfile',
|
||||
]
|
||||
|
||||
from pandac import PandaModules as pm
|
||||
@ -360,3 +361,10 @@ def getsize(path):
|
||||
raise os.error
|
||||
return file.getFileSize()
|
||||
|
||||
def execfile(path, globals=None, locals=None):
|
||||
file = _vfs.getFile(pm.Filename.fromOsSpecific(path), True)
|
||||
if not file:
|
||||
raise os.error
|
||||
|
||||
data = file.readFile(False)
|
||||
exec(data, globals, locals)
|
||||
|
Loading…
x
Reference in New Issue
Block a user