91 lines
1.7 KiB
D
91 lines
1.7 KiB
D
module cm3d2.arc;
|
|
|
|
import std.file;
|
|
import std.mmfile;
|
|
|
|
import dfuse.fuse;
|
|
|
|
import cm3d2;
|
|
|
|
class WarcFile
|
|
{
|
|
private MmFile _file;
|
|
|
|
this(MmFile file)
|
|
{
|
|
_file = file;
|
|
|
|
readHeader();
|
|
}
|
|
|
|
private void readHeader()
|
|
{
|
|
auto data = cast(ubyte[]) _file[];
|
|
|
|
auto type = cast(string) data.readBytes(4);
|
|
assert(type == "warc", "Invalid warc file: " ~ type);
|
|
}
|
|
}
|
|
|
|
class WarpFile
|
|
{
|
|
private MmFile _file;
|
|
|
|
this(MmFile file)
|
|
{
|
|
_file = file;
|
|
|
|
readHeader();
|
|
}
|
|
|
|
private void readHeader()
|
|
{
|
|
auto data = cast(ubyte[]) _file[];
|
|
|
|
auto type = cast(string) data.readBytes(4);
|
|
assert(type == "warp", "Invalid warp file: " ~ type);
|
|
}
|
|
}
|
|
|
|
class ArcFileSystem : Operations
|
|
{
|
|
private string[] _arcPaths;
|
|
private WarcFile[] _warcFiles;
|
|
private WarpFile[] _warpFiles;
|
|
|
|
this(string[] arcPaths)
|
|
{
|
|
import std.stdio;
|
|
|
|
foreach (path; arcPaths)
|
|
{
|
|
assert(path.exists);
|
|
|
|
stderr.write(path ~ ": ");
|
|
|
|
auto mmfile = new MmFile(path);
|
|
auto type = cast(string) mmfile[0 .. 4];
|
|
if (type == "warc")
|
|
{
|
|
_warcFiles ~= new WarcFile(mmfile);
|
|
|
|
stderr.writeln("warc");
|
|
}
|
|
else if (type == "warp")
|
|
{
|
|
_warpFiles ~= new WarpFile(mmfile);
|
|
|
|
stderr.writeln("warp");
|
|
}
|
|
else
|
|
{
|
|
assert(false, path ~ ": not a valid .arc file");
|
|
}
|
|
}
|
|
|
|
stderr.writeln(".arc files checked");
|
|
|
|
throw new Exception("Not implemented yet");
|
|
}
|
|
}
|