Adding a VPK to a search path via code

Grab your favourite IDE and tinker with the innards of game engines

Adding a VPK to a search path via code

Postby SM Sith Lord on Tue Oct 14, 2014 12:40 pm

I am using Source SDK Base 2013 Multiplayer and all I want to do is add a VPK to the "MOD" search path.

The VPK gets added to the search path, but files inside of the VPK do not get detected by the filesystem. Using this same code, if I mount a regular folder instead, the files inside of it are detected by the filesystem just fine, so I don't understand why it isn't working for VPKs.

Code: Select all
   char buf[MAX_STRING_LENGTH];
   filesystem->GetSearchPath("MOD", true, buf, sizeof(buf) - 1);

   DevMsg("Search Paths: %s\n", buf);

   KeyValues* pFilesKV = new KeyValues("files");

   std::string VPKBasePath = "juju/TesterThing.vpk";
   filesystem->AddSearchPath(VarArgs("%s/%s", engine->GetGameDirectory(), VPKBasePath.c_str()), "MOD");

   char buf2[MAX_STRING_LENGTH];
   filesystem->GetSearchPath("MOD", true, buf2, sizeof(buf2) - 1);
   DevMsg("xxxSearch Paths: %s\n", buf2);


I know the pending SDK update has a lot of changes to the filesystem, but I hope that mounting a VPK like this isn't something I have to wait for the new update to do.

Does anybody know why I can't access the files inside of the VPK this way?
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: Adding a VPK to a search path via code

Postby SM Sith Lord on Tue Oct 14, 2014 6:39 pm

I've determined that the VPK resources are being mounted, mostly, but not completely.

If I run this g_pFullFileSystem->FindFirstEx("*", "MOD", &testHandle) it does not find any results, however, if I use "models/*" instead, it will indeed show the contents of the newly mounted VPK.

Does anybody know how to get a root file listing from the VPK?

g_pFullFileSystem->IsDirectory() does not work from within VPK files either, it always returns as not a directory.

And here is a better explanation of the general issue:

I'm trying to get all files and folders contained within the VPK. To do this, I add the VPK as its own search path and use FindFirstEx recursively to build a list of everything that is in the VPK.

The issue is that FindFirstEx does not seem to work correctly when used at the root level of a VPK search path. It doesn't find any files or folders. However, it works correctly on any level deeper than the root.

I was able to get around this issue so far because I know the folder names that will exist in the VPK's root. I start the scan on that level, for example FindFirstEx with "models/*" and it will build the list of all files and folders in that branch, then I have it search the other important folders I care about in the same way.

This is all because FindFirstEx does not work correctly at the root level of a VPK search path.

Btw this is with the Source SDK Base 2013 Multiplayer.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Return to Programming

Who is online

Users browsing this forum: No registered users