www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - simple VFS implementation

reply ketmar <ketmar ketmar.no-ip.org> writes:
here[1] you can get a simple VFS system (yep, another one!). it 
introduces `VFile` struct (kinda like `std.stdio.File`, but with 
less features), which can wrap your own custom streams, 
`std.stdio.File`, libc `FILE*`, integer file descriptor... 
actually, anything you'll do a simple wrapper for. it's designed 
in the spirit of `fopencookie()`.

also it includes VFS features like "pak file registration", and 
built-in ZIP reader.

ZIP reader doesn't use `std.zip`, and doesn't unpack the whole 
file in memory. it is even possible to register ZIP inside ZIP as 
"pak" file! ;-)

also, it has functions to read and write numbers of various sizes 
in both endiannesses.

VFile i/o is thread-safe (but not VFile itself!)

works with DMD 2.070+

GNU GPL. i wanted you to read the whole text to find this, yeah.


1. http://repo.or.cz/iv.d.git/tree/HEAD:/vfs
Mar 30 2016
next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
oops. almost forgot to mention that it works only with POSIX 
systems now. windoze port *may* be done in the future (it's not 
that hard — basically, replace fopen/fseek/etc. imports and 
calls). sure, you can DIY and send me a patch too.
Mar 30 2016
prev sibling next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
p.s. it's only for opening files with known names and doing file 
i/o. it doesn't support other FS operations (like getting list of 
files, or file renaming), as i wrote it for using in my game 
engines, and i don't need such operations there. so i won't add 
that, it's out of scope of the library.
Mar 30 2016
prev sibling next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
iv.vfs gained ability to list files in all registered VFSes, and 
it now can open disk files regardless of name case on POSIX 
systems (this is controlled by global flags, or additional 
letters «i» and «I» in file mode arg).
Apr 27 2016
prev sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
contrary to what i said ealier, there is now a way to get list of 
known files, with their times and packed size (if containter 
supports that feature).

zip reader now understands all standard zip methods (including 
"shrink", "reduce" and "implode"), and LZMA (no external lzma 
library required). currently there are no plans to support BZip2 
and PPMd compression.

internal structures creates less pressure on GC and way less 
false positives: instead of registering the whole allocated 
memory "just in case", getPointerBitmap is used to register only 
pointers. and many internal structs doesn't have GC pointers at 
all.

added iv.vfs.io module, so it is possible to use good old 
`write*`, `readf`, `readln` API on VFile. it also wraps standard 
input and output, so to do console i/o you now can import 
iv.vfs.io instead of std.stdio. there is also `byLine` and 
`byLineCopy` API. not a speed demon, tho, so i'd not try to 
process terrabytes of text data with it.

added zip creation module.

not really new, but worth mentioning anyway: there is nice API to 
read/write endianness-neutral numeric values. readNum!T and 
writeNum!T. and `rawReadExact()` low-level API, to read the whole 
buffer or throw.

added Ken Silverman's GRP support. i had to mention it somewhere.
Dec 12 2016