Darkplaces virtual file system
Line 2: | Line 2: | ||
The goals it provides: | The goals it provides: | ||
− | + | ||
* opaque access to separate gamedir storing all writeable files (My Documents/My Games) | * opaque access to separate gamedir storing all writeable files (My Documents/My Games) | ||
* access files in archives just like they were stored on HDD | * access files in archives just like they were stored on HDD | ||
Line 8: | Line 8: | ||
* safety (gamecode cannot damage game files) | * safety (gamecode cannot damage game files) | ||
− | + | = How file table is maked = | |
# First gamedir is processed | # First gamedir is processed | ||
Line 15: | Line 15: | ||
## Real files stored in gamedir is processed and overlap files in archives | ## Real files stored in gamedir is processed and overlap files in archives | ||
# Next gamedir is processed | # Next gamedir is processed | ||
+ | |||
+ | = Quirks = | ||
+ | |||
+ | Since virtual file system is, effectively, an abstraction layer, it has its own quirks. | ||
+ | |||
+ | === 1. Homedir may be different than basedir === | ||
+ | |||
+ | This means config.cfg, screenshots etc. are stored in different directory, like in "My Documents/My Games/gamedir" | ||
+ | |||
+ | === 2. For written files, "data/" are automatically added === | ||
+ | |||
+ | When QC writes any files, system automatically adds 'data/' to the path, so gamecode cannot damage game files, maps etc. But file read is not the same. It could read files from base directory, open maps etc. So if you write, for examplem foo.txt (which will be written to data/foo.txt) and have foo.txt in basedir, you should set path "data/foot.txt" when reading the file, and set path "foo.txt" when writing. If you dont, you will write to file under "data/", but read file that is in basedir. | ||
+ | |||
+ | === 3. "." and ".." is no allowed === | ||
+ | |||
+ | To protect gamecode from damaging files, any use of "." and ".." directory operators is forbidden. |
Revision as of 18:29, 12 July 2012
Darkplaces virtual file system is file table that combines real file system and files stored in game archives.
The goals it provides:
- opaque access to separate gamedir storing all writeable files (My Documents/My Games)
- access files in archives just like they were stored on HDD
- mod support (mods can override files, add new files)
- safety (gamecode cannot damage game files)
Contents |
How file table is maked
- First gamedir is processed
- Archives processed sequentally (by alphabetical order), files with same name gets overlapped
- Files with empty contents overlapping other files, makes them 'deleted' to the file system
- Real files stored in gamedir is processed and overlap files in archives
- Next gamedir is processed
Quirks
Since virtual file system is, effectively, an abstraction layer, it has its own quirks.
1. Homedir may be different than basedir
This means config.cfg, screenshots etc. are stored in different directory, like in "My Documents/My Games/gamedir"
2. For written files, "data/" are automatically added
When QC writes any files, system automatically adds 'data/' to the path, so gamecode cannot damage game files, maps etc. But file read is not the same. It could read files from base directory, open maps etc. So if you write, for examplem foo.txt (which will be written to data/foo.txt) and have foo.txt in basedir, you should set path "data/foot.txt" when reading the file, and set path "foo.txt" when writing. If you dont, you will write to file under "data/", but read file that is in basedir.
3. "." and ".." is no allowed
To protect gamecode from damaging files, any use of "." and ".." directory operators is forbidden.