Based on stormlib, refer to the zipfilesystem of N3 to implement an mpqfilesystem
Note that '/' cannot be used in the file path, and '/' @ _ @ is used '//'@_@
The file in the mpq package does not save the file name (or directory name), that is, the packaged file is irreversible. however, there is a listfile file under the root directory of each package, which contains the file name list in the package.
(Why does the listfile file end with an empty string ???)
The Write function is not implemented. Although stormlib can add files, you only need to read the files for the game.
Mpq has an advantage over zip, that is, you can perform seek... this will support streaming file loading.
In addition, special compression algorithms can be used for wav to increase the compression ratio. However, I'm not very impressed with WAV...
Xact can be used to play xwma and DirectShow can be used to play WMV (I am dizzy, why am I mixed up with M $? No way, who is fmod and other commercial fees)
Well... Remember to test after writing... (Boss says this is a professional expression -_-)
// Configure <br/>/** <br/> */<br/> void <br/> mpqfilesystemtest: Run () <br/>{< br/> PTR <ioserver> ioserver = ioserver: Create (); <br/> PTR <mpqfilesystem> mpqfilesystem = mpqfilesystem: Create (); <br/> PTR <mpqarchive> patch2 = mpqfilesystem-> Mount ("file: // E:/World of Warcraft/data/patch-2.MPQ "); <br/> n_assert (patch2.isvalid (); <br /> Const array <string> & filelist = patch2-> getfilelist (); <br/> n_assert (! Filelist. isempty (); <br/> for (indext I = 0; I <filelist. size (); ++ I) <br/>{< br/> n_printf ("% s/n", filelist [I]. ascharptr (); <br/>}< br/> n_assert (patch2-> isfileexsit ("creature/ogre. m2 "); <br/> array <string> spellfiles = patch2-> listfiles (" spells ","*. * "); <br/> for (indext I = 0; I <spellfiles. size (); ++ I) <br/>{< br/> n_printf ("% s/n", spellfiles [I]. ascharptr (); <br/>}< br/> array <s Tring> creaturedirs = patch2-> listdirectories ("creature", "*"); <br/> for (indext I = 0; I <creaturedirs. size (); ++ I) <br/>{< br/> n_printf ("% s/n", creaturedirs [I]. ascharptr (); <br/>}< br/> URI uri = "file: // E:/World of Warcraft/data/shaders/vertex/snowpoint. break "; <br/> PTR <mpqarchive> archive = mpqfilesystem-> findmpqarchivewithfile (URI); <br/> n_assert (archive = patch2); <br/> PTR <mpqfilest Ream> snowpoint = mpqfilestream: Create (); <br/> uri = "mpq: // E:/World of Warcraft/data/patch-2.MPQ? File = shaders/vertex/snowpoint. vertex "; <br/> snowpoint-> seturi (URI); <br/> snowpoint-> open (); <br/> array <char> buffer (snowpoint-> getsize (), 0, 0); <br/> snowpoint-> Read (& buffer. front (), snowpoint-> getsize (); <br/> snowpoint-> close (); <br/>}< br/>
Well, to make it easier, convert all the file names to lower-case ones .... but isn't it case sensitive in Linux? Will the package program written by Linux programmers also differentiate the file name's case sensitivity, Hoho ~