zip archive

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
kevin[be]
Posts: 23
Joined: Sun Dec 21, 2008 2:42 pm

zip archive

Post by kevin[be] »

Hi,

I store map data in an archive 'mapname.zip'
the archive contains:
-mapname.bmp
-mapname.txt
-and a few other files

all these zip files are in a folder \maps
how can i acces them?
i need a function to display all the possible maps to choose from (all the zip files in \maps) and when you select one i need to load the files in the archive to ram

any idea how to do this?
i've messed around endlessly with addZipFileArchive but i can't solve it

thanks in advance
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

First you create an IFileList (IFileSystem::createFilelist) of the folder where the map archives are stored. Then you can go through every file in the folder and check if it is a valid map file (maybe check the extension). Then if the users selects a map you can access it via its name and add it to the filesystem using IFileSystem::addZipFileArchive(). Then you can open the map data with IFileSystem::createAndOpenFile( "mapname.txt" )
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
kevin[be]
Posts: 23
Joined: Sun Dec 21, 2008 2:42 pm

Post by kevin[be] »

Sylence wrote:First you create an IFileList (IFileSystem::createFilelist) of the folder where the map archives are stored.
how do you do that?
can you give a few lines of sample code?
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Code: Select all

FileSystem->changeWorkingDirectoryTo( "path/to/maps" );
IFileList* fileList = FileSystem->createFileList();

for( u32 i=0; i<fileList->getFileCount(); ++i)
{
   stringc fileName = fileList->getFileName( i );

   // fileName now contains the name of a file in the folder
}

fileList->drop();
And to add the map archive and load the mapname.txt for example:

Code: Select all

FileSystem->addZipFileArchive( "path/to/maps/maparchive.zip" );

IReadFile* mapnameTxt = FileSystem->createAndOpenFile( "mapname.txt" );

// read the file

mapnameTxt->drop();
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
kevin[be]
Posts: 23
Joined: Sun Dec 21, 2008 2:42 pm

Post by kevin[be] »

Thanks, it works
Post Reply