Multifile() how to really use?

Hey I was looking in the manual and came across the multifile section. From there I thought I could use it as a patch system for my game. I’m almost to that point where I need to get it to work but i’m having some problems understand how it works. As of right now I can add items but I cant seem to be able to take items out (extract) or read whats in the .mf file.

I know i’m doing it wrong but this is what I thought how to do it.

from pandac.PandaModules import Multifile
mf = Multifile()
mf.openRead("game.mf")
for i in mf.getNumSubfiles():
  barIdx = mf.findSubfile(i)
  if barIdx != -1:
    print mf.readSubfile(barIdx)
    mf.extractSubfile(i, mf.getSubfileName())

Usually you wouldn’t extract files out of it, rather mount it to a virtual dir (e.g. /mf/) and then directly load stuff out of it, e.g. using loadModel("/mf/model.egg").
The model won’t really be in the /mf/ location, but to Panda, it will be.

Ok, I see. So really its just a way to put all the files into one and then call from that. Ty for the reply. ^^

Nvm I guess O.o; still cant seem to get it to work… v.v;

from pandac.PandaModules import Multifile
from pandac.PandaModules import VirtualFileSystem, Filename

mf = Multifile()
mf.openRead('game.mf')
vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(mf, "/mf", 0)

a = "/mf/New Folder/Downloading.txt"
f = open(a,"r")
b = f.readlines()
f.close()
print str(b)

You need to use Panda’s ‘open’ function rather than Python’s, which is not compatible with the VFS.
So just add this import line:

from direct.stdpy.file import *