Physicsfs is a library to provide abstract access to various archives. it is intended for use in video games, and the design was somewhat should be red by quake 3's file subsystem. the programmer defines a "Write directory" on the physical filesystem. no file writing done through the physicsfs API can leave that write directory, for security. for example, an embedded scripting language cannot write outside of this path if it uses physfs for all of its I/O, which means that untrusted scripts can run more safely. symbolic Links can be disabled as well, for added safety. for file reading, the programmer lists directories and archives that form a "Search Path ". once the search path is defined, it becomes a single, transparent hierarchical filesystem. this makes for easy access to zip files in the same way as you access a file directly on the disk, and it makes it easy to ship a new archive that will override a previous archive on a per-file basis. finally, physicsfs gives you platform-specific acted means to determine if CD-ROMs are available, the user's home directory, where in the real filesystem your program is running, etc.
I saw from the revised dosbox that such a technology can mount the zip/7z compressed package and want to use it in. net.
Let me find a encapsulated library, boogame, and Tao (the file is too large, there are more than 30 m ).
Download boogame first: http://sourceforge.net/projects/boogame/files/BooGame/
Find physfs. dll and Tao. physfs. dll in the downloaded package, create a project, reference Tao. physfs. dll, And put physfs. dll in the bin together with the execution file.
Then there is a filesystem. CS in using TAO. physfs and boogame, which can be used as a reference, but its encapsulation is not complete enough.
First, FS. physfs_init ("init"); // The "init" here has no special meaning. In short, you can pass in a string.
Then add the search path, FS. physfs_addtosearchpath ("D: \ Temp", 1); // if there is a write requirement, the temporary directory to be written must be added first. Otherwise, the modified data cannot be found, parameter 1 is a fixed value.
Mount a compressed package, FS. physfs_addtosearchpath ("D: \ test.zip", 1 );
Then, set the temporary directory for writing: fs. physfs_setwritedir ("d :\\"); // any modifications made to the compressed file will be saved to the temporary directory specified here.
If the temporary directory and the compressed package have the same files in the same path, the file in front of the search path will be used first.
The next step is the normal operation of the file directory. Except for statements such as FS. physfs_xxx, it is not much different from the common file operations. For more help, see http: // 192.121.234.229/manualer/programering/Tao-DOC/TAO. physfs/tao.physfs.fsmembers.html
If you are interested, you can consider inheriting steam to rewrite a class to simplify usage.
Note: openwrite and openappend in the directory are not easy to use (memory needs to be allocated by Marshal. allochglobal). It is better to directly read and write data in the temporary directory.
Finally, close the resource: fs. physfs_deinit ();
PS: This version is a bit old. It seems to be 1.0.1. The latest version is 2.0.2, And the 7z format is supported from 1.1.
I have almost finished writing it. I think it's too strange to copy the libphysfs. dll in the dosbox and change it to physfs. dll. Then I tried it. Haha, it can be used and the 7z format is supported.
Related file downloads: http://files.cnblogs.com/Icebird/PhysFS.net.rar