The DirectoryComponentBundler task doesn't create a single output stream for a jar file, so fout doesn't need to be closed at the end of the bundling

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@378 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2007-12-13 18:51:48 +00:00
parent 9d6fa8d4d5
commit 80a952de68
2 changed files with 19 additions and 22 deletions
@@ -171,15 +171,10 @@ public class ComponentBundlerTask extends Task
OutputStream fout = createOutputStream(_target); OutputStream fout = createOutputStream(_target);
// we'll fill this with component id to tuple mappings // we'll fill this with component id to tuple mappings
HashIntMap mapping = new HashIntMap(); HashIntMap<Tuple<String, String>> mapping = new HashIntMap<Tuple<String, String>>();
// herein we'll insert trimmed tileset objects that go along
// with each of the trimmed action images
HashIntMap actionSets = new HashIntMap();
// deal with the filesets // deal with the filesets
for (int i = 0; i < _filesets.size(); i++) { for (FileSet fs : _filesets) {
FileSet fs = (FileSet)_filesets.get(i);
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File fromDir = fs.getDir(getProject()); File fromDir = fs.getDir(getProject());
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();
@@ -203,7 +198,7 @@ public class ComponentBundlerTask extends Task
// obtain the component id from our id broker // obtain the component id from our id broker
int cid = broker.getComponentID(info[0], info[1]); int cid = broker.getComponentID(info[0], info[1]);
// add a mapping for this component // add a mapping for this component
mapping.put(cid, new Tuple(info[0], info[1])); mapping.put(cid, new Tuple<String, String>(info[0], info[1]));
// process and store the main component image // process and store the main component image
processComponent(info, aset, cfile, fout, newest); processComponent(info, aset, cfile, fout, newest);
@@ -231,8 +226,10 @@ public class ComponentBundlerTask extends Task
oout.flush(); oout.flush();
} }
// seal up our jar file if (fout != null) {
fout.close(); // seal up our jar file if we created one
fout.close();
}
} catch (IOException ioe) { } catch (IOException ioe) {
String errmsg = "Unable to create component bundle."; String errmsg = "Unable to create component bundle.";
@@ -266,7 +263,7 @@ public class ComponentBundlerTask extends Task
// stuff the new trimmed image into the jar file at the same time // stuff the new trimmed image into the jar file at the same time
aset.setImagePath(cfile.getPath()); aset.setImagePath(cfile.getPath());
TrimmedTileSet tset = null; TrimmedTileSet tset;
try { try {
tset = trim(aset, fout); tset = trim(aset, fout);
tset.setImagePath(ipath); tset.setImagePath(ipath);
@@ -283,17 +280,13 @@ public class ComponentBundlerTask extends Task
} }
// then write our trimmed tileset bundle data // then write our trimmed tileset bundle data
if (tset != null) { String tpath = composePath(info, BundleUtil.TILESET_EXTENSION);
if (!skipEntry(tpath, newest)) {
fout = nextEntry(fout, tpath);
String tpath = composePath( ObjectOutputStream oout = new ObjectOutputStream(fout);
info, BundleUtil.TILESET_EXTENSION); oout.writeObject(tset);
if (!skipEntry(tpath, newest)) { oout.flush();
fout = nextEntry(fout, tpath);
ObjectOutputStream oout = new ObjectOutputStream(fout);
oout.writeObject(tset);
oout.flush();
}
} }
} }
@@ -667,7 +660,7 @@ public class ComponentBundlerTask extends Task
protected String _root; protected String _root;
/** A list of filesets that contain tile images. */ /** A list of filesets that contain tile images. */
protected ArrayList _filesets = new ArrayList(); protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
/** Used to separate keys and values in the map file. */ /** Used to separate keys and values in the map file. */
protected static final String SEP_STR = " := "; protected static final String SEP_STR = " := ";
@@ -54,6 +54,10 @@ public class DirectoryComponentBundlerTask extends ComponentBundlerTask
{ {
File file = new File(_target, path); File file = new File(_target, path);
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
if (!file.getParentFile().isDirectory()) {
throw new IOException("Unable to make component directory.[dir=" +
file.getParentFile() + "]");
}
return new FileOutputStream(file); return new FileOutputStream(file);
} }