Exemple #1
0
  public void printStats(PrintStream ps) {
    AssetObjectPathTable pathTable = asset.getObjectPaths();
    Map<String, Integer> classCounts = new HashMap<>();
    Map<String, Integer> classSizes = new HashMap<>();

    for (AssetObjectPath path : pathTable) {
      String className = ClassID.getInstance().getNameForID(path.classID2, true);

      if (!classCounts.containsKey(className)) {
        classCounts.put(className, 0);
        classSizes.put(className, 0);
      }

      classCounts.put(className, classCounts.get(className) + 1);
      classSizes.put(className, classSizes.get(className) + path.length);
    }

    ps.println("Classes by quantity:");
    Map<String, Integer> classCountsSorted = MapUtils.sortByValue(classCounts, true);
    for (Map.Entry<String, Integer> entry : classCountsSorted.entrySet()) {
      String className = entry.getKey();
      int classCount = entry.getValue();
      ps.printf("  %s: %d\n", className, classCount);
    }

    ps.println("Classes by data size:");
    Map<String, Integer> classSizesSorted = MapUtils.sortByValue(classSizes, true);
    for (Map.Entry<String, Integer> entry : classSizesSorted.entrySet()) {
      String className = entry.getKey();
      String classSize = humanReadableByteCount(entry.getValue(), true);
      ps.printf("  %s: %s\n", className, classSize);
    }
    ps.println();
  }
Exemple #2
0
  public void printInfo(PrintStream ps) {
    AssetObjectPathTable objTable = asset.getObjectPaths();
    AssetRefTable refTable = asset.getReferences();
    AssetHeader header = asset.getHeader();
    AssetTypeTree fieldTree = asset.getTypeTree();

    ps.println("Header");
    ps.println("  File size: " + humanReadableByteCount(header.fileSize, true));
    ps.println("  Tree size: " + humanReadableByteCount(header.treeSize, true));
    ps.println("  Format: " + header.format);
    ps.println("  Data offset: " + header.dataOffset);
    ps.println("  Unknown: " + header.unknown);
    ps.println();

    ps.println("Serialized data");
    ps.println("  Revision: " + fieldTree.revision);
    ps.println("  Version: " + fieldTree.version);
    ps.println("  Standalone: " + (fieldTree.isStandalone() ? "yes" : "no"));
    ps.println("  Objects: " + objTable.size());
    ps.println();

    if (!refTable.isEmpty()) {
      ps.println("External references");
      for (AssetRef ref : refTable) {
        if (!ref.assetPath.isEmpty()) {
          ps.printf("  Asset path: \"%s\"\n", ref.assetPath);
        }
        if (!ref.filePath.isEmpty()) {
          ps.printf("  File path: \"%s\"\n", ref.filePath);
        }
        ps.printf("  GUID: %s\n", DatatypeConverter.printHexBinary(ref.guid));
        ps.printf("  Type: %d\n", ref.type);
        ps.println();
      }
    }
  }