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:
@@ -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;
|
package com.threerings.media.tile.bundle;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
@@ -40,4 +42,23 @@ public class BundleUtil
|
|||||||
StreamUtil.close(tbin);
|
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;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -24,7 +24,8 @@ public class DumpBundle
|
|||||||
boolean dumpTiles = false;
|
boolean dumpTiles = false;
|
||||||
|
|
||||||
if (args.length < 1) {
|
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.err.println(usage);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
@@ -42,9 +43,14 @@ public class DumpBundle
|
|||||||
|
|
||||||
File file = new File(args[i]);
|
File file = new File(args[i]);
|
||||||
try {
|
try {
|
||||||
ResourceBundle bundle = new ResourceBundle(file);
|
TileSetBundle tsb = null;
|
||||||
TileSetBundle tsb = BundleUtil.extractBundle(bundle);
|
if (args[i].endsWith(".jar")) {
|
||||||
tsb.init(bundle);
|
ResourceBundle bundle = new ResourceBundle(file);
|
||||||
|
tsb = BundleUtil.extractBundle(bundle);
|
||||||
|
tsb.init(bundle);
|
||||||
|
} else {
|
||||||
|
tsb = BundleUtil.extractBundle(file);
|
||||||
|
}
|
||||||
|
|
||||||
Iterator tsids = tsb.enumerateTileSetIds();
|
Iterator tsids = tsb.enumerateTileSetIds();
|
||||||
while (tsids.hasNext()) {
|
while (tsids.hasNext()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user