Search in sources :

Example 1 with SerializedFileReader

use of info.ata4.junity.serialize.SerializedFileReader in project disunity by ata4.

the class AssetCommand method runFileRecursive.

@Override
protected void runFileRecursive(Path file) {
    if (BundleUtils.isBundle(file)) {
        // file is a bundle, load serialized files from it
        try (BundleReader bundleReader = new BundleReader(file)) {
            Bundle bundle = bundleReader.read();
            bundle.entries().stream().filter(not(BundleEntry::isLibrary)).filter(not(BundleEntry::isResource)).forEach(uncheck(entry -> {
                try (SerializedFileReader reader = new SerializedFileReader(BundleUtils.dataReaderForEntry(entry))) {
                    SerializedFile serialized = reader.read();
                    runSerializedFile(file.resolve(entry.name()), serialized);
                }
            }));
        } catch (UncheckedIOException | IOException ex) {
            L.log(Level.WARNING, "Can't open asset bundle " + file, ex);
        }
    } else {
        // load file directly
        try (SerializedFileReader reader = new SerializedFileReader(file)) {
            SerializedFile serialized = reader.read();
            runSerializedFile(file, serialized);
        } catch (IOException ex) {
            L.log(Level.WARNING, "Can't open asset file " + file, ex);
        }
    }
}
Also used : RecursiveFileCommand(info.ata4.disunity.cli.command.RecursiveFileCommand) LogUtils(info.ata4.log.LogUtils) IOConsumer.uncheck(info.ata4.util.function.IOConsumer.uncheck) IOException(java.io.IOException) Logger(java.util.logging.Logger) BundleUtils(info.ata4.junity.bundle.BundleUtils) SerializedFile(info.ata4.junity.serialize.SerializedFile) Predicates.not(info.ata4.util.function.Predicates.not) Level(java.util.logging.Level) BundleEntry(info.ata4.junity.bundle.BundleEntry) UncheckedIOException(java.io.UncheckedIOException) Bundle(info.ata4.junity.bundle.Bundle) SerializedFileReader(info.ata4.junity.serialize.SerializedFileReader) BundleReader(info.ata4.junity.bundle.BundleReader) Path(java.nio.file.Path) SerializedFileReader(info.ata4.junity.serialize.SerializedFileReader) SerializedFile(info.ata4.junity.serialize.SerializedFile) Bundle(info.ata4.junity.bundle.Bundle) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) BundleEntry(info.ata4.junity.bundle.BundleEntry) BundleReader(info.ata4.junity.bundle.BundleReader)

Aggregations

RecursiveFileCommand (info.ata4.disunity.cli.command.RecursiveFileCommand)1 Bundle (info.ata4.junity.bundle.Bundle)1 BundleEntry (info.ata4.junity.bundle.BundleEntry)1 BundleReader (info.ata4.junity.bundle.BundleReader)1 BundleUtils (info.ata4.junity.bundle.BundleUtils)1 SerializedFile (info.ata4.junity.serialize.SerializedFile)1 SerializedFileReader (info.ata4.junity.serialize.SerializedFileReader)1 LogUtils (info.ata4.log.LogUtils)1 IOConsumer.uncheck (info.ata4.util.function.IOConsumer.uncheck)1 Predicates.not (info.ata4.util.function.Predicates.not)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Path (java.nio.file.Path)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1