About Store Forum Documentation Contact



Post Reply 
FileFind for paks
Author Message
Kevin Offline
Member

Post: #1
FileFind for paks
Hi,

In my application I need to access the name of all the waypoints in the current world. I only found a method to access them by name, but no method to access them by index (and to get the number of waypoints).

Therefore I decided to search directly in the folder structure, all the waypoints are stored in the [Game.World.gameDir()]/Waypoint.
This works fine as long as I use folder, but for Android I have to use paks, so I tried to do the same thing with paks.
However, it doesn't work.

Code:
Memb<Str> waypoints;
      
      // Search for waypoints:
      Str dir = S+Game::World.gameDir()+"Waypoint";   // The directory of all the waypoints
      // Check if dir exists:
      DEBUG_ASSERT(FExist(dir), "Directory doesn't exist!");
      
      for(FileFind ff(dir); ff();)
      {
         if(ff.type == FSTD_FILE)
         {
            waypoints.add(ff.name);            
         }
      }

Well, the directory is found by the application but it seems like FileFind ignores all the paks, because the Memb is empty after the loop has finished...

But there definitely is something in the Waypoint folder. When I do this, the application also detects that the file exists:

Code:
Str file= S+Game::World.gameDir()+"Waypoint/Route1";  

DEBUG_ASSERT(FExist(file), "Waypoint file doesn't exist!");

Is this a bug or is that a limitiation of the FileFinder? How do I search for files in pak containers?
Or did I do something wrong?

Thanks in advance.
07-11-2012 03:01 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #2
RE: FileFind for paks
If you want get access to files in Pak check this tutorial:

Advanced\1 - Geometry, Graphics, Gui, Misc, Net, Sound\Files\08 - Pak Create.cpp

Simply you have to load paks first.
07-11-2012 03:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #3
RE: FileFind for paks
Yeah, I already saw this tutorial.

What I read in those tutorials is, that you can use all the File classes and functions also with files located in paks, after you loaded them.
But the FileFind class doesn't seem to work with pak files and that's the only one i need...

Is there another way to find all files in a specific pak file directory?

Or is there another way to get all the waypoints in a world?
07-11-2012 03:44 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: FileFind for paks
It's a very quick idea but you can create Container for your Waypoints (or Cache because I see that there is one for waypoints, but never played with them) and name your Waypoints starting from 0 (0,1,2 etc.). Then you can use loop to go through all Waypoints in directory using this method:

Game::World.findWaypoint(S+"directory name"+i) where i is your loop iterator. When this method will return NULL then you'll end the loop.

Similar thing I've found in tutorial about Waypoints.
(This post was last modified: 07-11-2012 04:10 PM by Harry.)
07-11-2012 04:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #5
RE: FileFind for paks
Thanks, works fine now.

However, maybe the thing with FileFind was a bug. Esenthel, if you read this topic, could you check this please? wink
07-11-2012 04:53 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: FileFind for paks
FileFind does not operate on Pak's,
you can manually iterate files in paks (check the Pak and PakSet headers, they provide you methods to access all of their files)
07-13-2012 01:37 PM
Find all posts by this user Quote this message in a reply
Post Reply