private void loadDir(ByteArrayInputStream fnt, string dirName, int dirID, Directory parent) { fnt.savePos(); fnt.seek(8 * (dirID & 0xFFF)); uint subTableOffs = fnt.readUInt(); int fileID = fnt.readUShort(); //Crappy hack for MKDS course .carc's. //Their main dir starting ID is 2, which is weird... // if (parent == mainDir) fileID = 0; Directory thisDir = new Directory(this, parent, false, dirName, dirID); addDir(thisDir); parent.childrenDirs.Add(thisDir); fnt.seek((int)subTableOffs); while (true) { byte data = fnt.readByte(); int len = data & 0x7F; bool isDir = (data & 0x80) != 0; if (len == 0) { break; } String name = fnt.ReadString(len); if (isDir) { int subDirID = fnt.readUShort(); loadDir(fnt, name, subDirID, thisDir); } else { loadFile(name, fileID, thisDir); fileID++; } } fnt.loadPos(); }
private void loadDir(ByteArrayInputStream fnt, string dirName, int dirID, Directory parent) { fnt.savePos(); fnt.seek(8 * (dirID & 0xFFF)); uint subTableOffs = fnt.readUInt(); int fileID = fnt.readUShort(); //Crappy hack for MKDS course .carc's. //Their main dir starting ID is 2, which is weird... // if (parent == mainDir) fileID = 0; Directory thisDir = new Directory(this, parent, false, dirName, dirID); addDir(thisDir); parent.childrenDirs.Add(thisDir); fnt.seek((int)subTableOffs); while (true) { byte data = fnt.readByte(); int len = data & 0x7F; bool isDir = (data & 0x80) != 0; if (len == 0) break; String name = fnt.ReadString(len); if (isDir) { int subDirID = fnt.readUShort(); loadDir(fnt, name, subDirID, thisDir); } else { loadFile(name, fileID, thisDir); fileID++; } } fnt.loadPos(); }