this.cf = cf;
}
public void extract(boolean raw) throws IOException {
List<ObjectPath> paths = asset.getPaths();
Deserializer deser = new Deserializer(asset);
for (AssetExtractHandler extractHandler : extractHandlerMap.values()) {
extractHandler.setAssetFile(asset);
extractHandler.setOutputDir(outputDir);
}
for (ObjectPath path : paths) {
// skip filtered classes
if (cf != null && !cf.accept(path)) {
continue;
}
String className = ClassID.getNameForID(path.getClassID(), true);
// write just the serialized object data or parsed and extracted content?
if (raw) {
String assetFileName = String.format("%06d.bin", path.getPathID());
Path classDir = outputDir.resolve(className);
if (Files.notExists(classDir)) {
Files.createDirectories(classDir);
}
Path assetFile = classDir.resolve(assetFileName);
L.log(Level.INFO, "Writing {0} {1}", new Object[] {className, assetFileName});
ByteBuffer bbAsset = asset.getPathBuffer(path);
try {
ByteBufferUtils.save(assetFile, bbAsset);
} catch (Exception ex) {
L.log(Level.WARNING, "Can't write " + path + " to " + assetFile, ex);
}
} else {
AssetExtractHandler handler = getHandler(className);
if (handler != null) {
UnityObject obj;
try {
obj = deser.deserialize(path);
} catch (Exception ex) {
L.log(Level.WARNING, "Can't deserialize " + path, ex);
continue;
}