I have a binary file that really is a stack of files, format:
lengh_of_subfile,subfile
length_of_subfile is a 64-bit integer. I can read long without any problems, but when I try to create a buffer for a subfile, I get compilation errors saying that it cannot be read at compile time. What am I missing? I wrote an identical extraction tool in erlang, PHP and C # ... D throws me in a loop.
void main(string args[]) { Stream file = new BufferedFile(args[1], FileMode.In); int counter = 0; while(file.position < file.size) { ulong len; file.read(len); ubyte[len] ogg; file.read(ogg); string outname = getcwd() ~ "/" ~ to!string(counter) ~ ".ogg"; Stream oggout = new BufferedFile(outname, FileMode.OutNew); oggout.write(ogg); writefln("Creating file " ~ to!string(counter) ~ ".ogg"); counter++; } }
source share