mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -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.
|
# the multifile.
|
||||||
__builtin__.file = file.file
|
__builtin__.file = file.file
|
||||||
__builtin__.open = file.open
|
__builtin__.open = file.open
|
||||||
|
__builtin__.execfile = file.execfile
|
||||||
os.listdir = file.listdir
|
os.listdir = file.listdir
|
||||||
os.walk = file.walk
|
os.walk = file.walk
|
||||||
os.path.join = file.join
|
os.path.join = file.join
|
||||||
|
@ -7,6 +7,7 @@ for I/O to complete. """
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'file', 'open', 'listdir', 'walk', 'join',
|
'file', 'open', 'listdir', 'walk', 'join',
|
||||||
'isfile', 'isdir', 'exists', 'lexists', 'getmtime', 'getsize',
|
'isfile', 'isdir', 'exists', 'lexists', 'getmtime', 'getsize',
|
||||||
|
'execfile',
|
||||||
]
|
]
|
||||||
|
|
||||||
from pandac import PandaModules as pm
|
from pandac import PandaModules as pm
|
||||||
@ -360,3 +361,10 @@ def getsize(path):
|
|||||||
raise os.error
|
raise os.error
|
||||||
return file.getFileSize()
|
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