While digging around the internet in search of a tool that would allow me to extract sound files from a Java container, I found a 4+ year old bit of D code. Unfortunately, I couldn't get it to compile, and discovered upon searching Google that std.stream had been deprecated. I have never worked with D before now, however, and I can't find any clear-cut ideas on how to bring this pre-stream-death code up to speed. Are there any current D programmers who can help me out?
EDIT: I have picked up the undead src files stream and related files, but I am now having an int property issue. According to the forum where I found this code, it worked at the time of posting 4 years ago so I can't imagine that the 'files.sort' is inherently problematic.
import std.stdio;
import std.file;
import std.conv;
import std.stream;
import std.bitmanip;
void main(string args[]){
Stream pkfile = new BufferedFile(args[1],FileMode.In);
int headersize;
int counter = 0;
int filecount;
int throwaway;
int offset;
pkfile.read(headersize);
pkfile.read(filecount);
writefln("Count is : " ~ to!string(filecount));
int[] files = new int[filecount];
for(int x = 0; x < filecount; x++)
{
pkfile.read(throwaway);
pkfile.read(offset);
files[x] = offset + (headersize + 4);
}
files = files.sort;
for(int x =0; x < filecount; x++)
{
pkfile.seekSet(cast(long)files[x]);
long len;
pkfile.read(len);
int newlen = cast(int)len;
ubyte[] ogg = new ubyte[newlen];
pkfile.read(ogg);
string outname = getcwd() ~"/"~ to!string(counter) ~ ".ogg";
Stream oggout = new BufferedFile(outname,FileMode.OutNew);
oggout.write(shiftL(ogg,newlen));
oggout.close();
writefln("Creating file " ~ to!string(counter) ~".ogg");
counter++;
}
}
ubyte[] shiftL(ubyte[] ogg,int ogglength){
ubyte[] temp = new ubyte[ogglength];
for(int x = 0;x < ogglength;x++){
temp[x] = cast(byte)(ogg[x]-1);
}
return temp;
}
files.sort();). - Richard Andrew Cattermole