May 29, 2005

ZipFileSystem Class

I uploaded my first pass at a ZipFileSystem class to the RSEngine page. This does require use of SharpZipLib 0.8.3a or higher.

It's pretty easy to use, and it allows "pure" vs. "impure" file loads as well.

Usage:
        ZipFileSystem.AddDirToFileSystem("C:\DOOM3\BASE", ".PK4", True)
Dim sr As New System.IO.StreamReader(ZipFileSystem.OpenFile("maps/game/mp/d3dm1.map"))
Debug.WriteLine(sr.ReadToEnd)
sr.Close()
The first parameter is that of the directory you want added to the file system. You can stack multiple directories, and duplicated names will be overriden by later files.

The second parameter is that of the archive extension you wish to use. Doom 3 uses .PK4 for their extension, hence the .PK4 in the parameter.

The final parameter should be set to False if you want to allow non-packed files in that directory to override files in the archives. If you set it to False and there is a non-packed file in that directory, the IsTrue() shared function in the class will return False.

If you call OpenFile for a file that doesn't exist, OpenFile returns Nothing/Null.

You can also reset the file system should you want to go back to pure or allow impure files. A later version will return a pure CRC64 that can be used for matchmaking purposes.

No comments: