Accessing the path of compiled p3d file

Hi everyone,

My project needs to access a directory that is outside of the compiled p3d multifile and so I’m looking for a way to identify the path of the p3d file itself. The contents of the accessed directory may be changed while the game is running, so it cannot be included in the p3d file.

I can make certain assumptions, for example, that folder to be read from exists in the same directory as the p3d file. I’ve tried a range of solutions, with poor results. Is the location of the p3d file available inside a Panda3D internal, or must I resort to setting an environment variable?

sys.path[0]+"/folder"
# -> /User/d/library/Caches/Panda3D/hosts/runtime.panda.../panda3d/cmu_1.7/P3DPython.app/Contents/MacOS

base.appRunner.multifileRoot+"/../folder"   
# -> 
OSError: No such file or directory: /mf/../folder

Thanks!
Dustin

Hi, is it necessary to find the path of the p3d file, or do you only want a directory outside the p3d file, that can be a specific directory for your application?

If so, my game normally downloads maps to the users computer from my web server, now I needed a place to store them outside the p3d (p3d’s are read only) and then I wanted them to stay on their computer (unless they removed them of course) so what I did was added ‘start_dir=mygame’ to my “packp3d -o mygame.p3d” line, this makes a folder for your application right on their computer for your application to store data outside the p3d, after that you can simply use something like

f = open("myfile", 'w')
f.write('testing..')
f.close()

and it will make a ‘myfile’ inside your ‘mygame’ directory existing in the following places:

Linux:
~/.panda3d/start/mygame/

Windows 7:
C:\Users<name>\AppData\Local\Panda3D\start\mygame\

I forgot what they are on windows XP and mac, they should be relatively easy to find though, I’d look myself, I have no mac or XP machine available though

~powerpup118