Added support for dumping a bundle metadata file directly in addition to

extracting it from a bundle.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2732 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-07-28 04:07:30 +00:00
parent 42b84f894f
commit 7961683cb0
2 changed files with 33 additions and 6 deletions
@@ -1,9 +1,11 @@
//
// $Id: BundleUtil.java,v 1.3 2003/05/14 21:34:01 ray Exp $
// $Id: BundleUtil.java,v 1.4 2003/07/28 04:07:30 mdb Exp $
package com.threerings.media.tile.bundle;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -40,4 +42,23 @@ public class BundleUtil
StreamUtil.close(tbin);
}
}
/**
* Extracts, but does not initialize, a serialized tileset bundle
* instance from the supplied file.
*/
public static TileSetBundle extractBundle (File file)
throws IOException, ClassNotFoundException
{
// unserialize the tileset bundles array
FileInputStream fin = new FileInputStream(file);
try {
ObjectInputStream oin = new ObjectInputStream(
new BufferedInputStream(fin));
TileSetBundle tsb = (TileSetBundle)oin.readObject();
return tsb;
} finally {
StreamUtil.close(fin);
}
}
}
@@ -1,5 +1,5 @@
//
// $Id: DumpBundle.java,v 1.10 2003/05/13 21:33:58 ray Exp $
// $Id: DumpBundle.java,v 1.11 2003/07/28 04:07:30 mdb Exp $
package com.threerings.media.tile.bundle.tools;
@@ -24,7 +24,8 @@ public class DumpBundle
boolean dumpTiles = false;
if (args.length < 1) {
String usage = "Usage: DumpBundle bundle.jar [bundle.jar ...]";
String usage = "Usage: DumpBundle [-tiles] " +
"(bundle.jar|tsbundle.dat) [...]";
System.err.println(usage);
System.exit(-1);
}
@@ -42,9 +43,14 @@ public class DumpBundle
File file = new File(args[i]);
try {
ResourceBundle bundle = new ResourceBundle(file);
TileSetBundle tsb = BundleUtil.extractBundle(bundle);
tsb.init(bundle);
TileSetBundle tsb = null;
if (args[i].endsWith(".jar")) {
ResourceBundle bundle = new ResourceBundle(file);
tsb = BundleUtil.extractBundle(bundle);
tsb.init(bundle);
} else {
tsb = BundleUtil.extractBundle(file);
}
Iterator tsids = tsb.enumerateTileSetIds();
while (tsids.hasNext()) {