Leadwerks Abstract File System

BlitzMax Forums/BlitzMax Programming/Leadwerks Abstract File System

JoshK(Posted 2007) [#1]
I was coincidentally dealing with package formats when Noel put his PhysFS module up. I took some ideas from that and wrote a file system and package reader using ZipEngine.

http://www.leadwerks.com/post/AFS.zip

You start by registering the file path, returning a "Virtual Directory":
vd:TVirtualDir=RegisterPath(AppDir)


You can then go through the files and folders recursively:
For vf:TVirtualFile=EachIn vd
	print vf.url
Next
For sd:TVirtualDir=EachIn vd
	'Do something...
Next


This will treat zip file contents just as if they were in the same directory as the zip file. It will also handle zip directory structures. For example, a "materials" folder in the mypak.zip package is considered the same virtual folder as the "materials" folder on the hard drive.

To read a virtual file:
If vf stream:TStream=vf.Read()


This will either load the real file, or extract and load a temp file from its package file. You don't care where it comes from, you just want the file. Files with the same names in different virtual directories are accounted for, of course.

I think the best aspect of this is you can add new package formats by extending the TPackageReader type, as I did to make the zip reader. Nem's tools has a HL2 package lib, and it would be nice to see that working.


Picklesworth(Posted 2007) [#2]
This sounds a bit like GnomeVFS (which I've been recently learning about) (if you know what that is).

Do you have plans for transparent access to files over the Internet and the like?


JoshK(Posted 2007) [#3]
Hell no.


N(Posted 2007) [#4]
Will take a look at this once I manage to fully wake up. Should be pretty good though.


JoshK(Posted 2007) [#5]
This will display the contents of the Q3A directory. Double-click a file to extract and launch it.