Path related fixes to make things work on Windows. Courtesy of
Patrick @onyxbits.de. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1098 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -383,30 +383,26 @@ public class ComponentBundlerTask extends Task
|
|||||||
{
|
{
|
||||||
// first strip off the root
|
// first strip off the root
|
||||||
if (!path.startsWith(_root)) {
|
if (!path.startsWith(_root)) {
|
||||||
throw new BuildException("Can't bundle images outside the " +
|
throw new BuildException("Can't bundle images outside the root directory " +
|
||||||
"root directory [root=" + _root +
|
"[root=" + _root + ", path=" + path + "].");
|
||||||
", path=" + path + "].");
|
|
||||||
}
|
}
|
||||||
path = path.substring(_root.length());
|
path = path.substring(_root.length());
|
||||||
|
|
||||||
// strip off any preceding slash
|
// strip off any preceding file separator
|
||||||
if (path.startsWith("/")) {
|
if (path.startsWith(File.separator)) {
|
||||||
path = path.substring(1);
|
path = path.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now strip off the file extension
|
// now strip off the file extension
|
||||||
if (!path.endsWith(BundleUtil.IMAGE_EXTENSION)) {
|
if (!path.endsWith(BundleUtil.IMAGE_EXTENSION)) {
|
||||||
throw new BuildException("Can't bundle malformed image file " +
|
throw new BuildException("Can't bundle malformed image file [path=" + path + "].");
|
||||||
"[path=" + path + "].");
|
|
||||||
}
|
}
|
||||||
path = path.substring(0, path.length() -
|
path = path.substring(0, path.length() - BundleUtil.IMAGE_EXTENSION.length());
|
||||||
BundleUtil.IMAGE_EXTENSION.length());
|
|
||||||
|
|
||||||
// now decompose the path; the component type and action must
|
// now decompose the path; the component type and action must always be a single string but
|
||||||
// always be a single string but the class can span multiple
|
// the class can span multiple directories for easier component organization; thus
|
||||||
// directories for easier component organization; thus
|
// "male/head/goatee/standing" will be parsed as
|
||||||
// "male/head/goatee/standing" will be parsed as [class=male/head,
|
// [class=male/head, type=goatee, action=standing]
|
||||||
// type=goatee, action=standing]
|
|
||||||
String malmsg = "Can't decode malformed image path: '" + path + "'";
|
String malmsg = "Can't decode malformed image path: '" + path + "'";
|
||||||
String[] info = new String[3];
|
String[] info = new String[3];
|
||||||
int lsidx = path.lastIndexOf(File.separator);
|
int lsidx = path.lastIndexOf(File.separator);
|
||||||
@@ -420,18 +416,19 @@ public class ComponentBundlerTask extends Task
|
|||||||
}
|
}
|
||||||
info[1] = path.substring(slsidx+1, lsidx);
|
info[1] = path.substring(slsidx+1, lsidx);
|
||||||
info[0] = path.substring(0, slsidx);
|
info[0] = path.substring(0, slsidx);
|
||||||
|
// we need to turn file separator characters (platform dependent) into jar path separator
|
||||||
|
// characters (always forward slash)
|
||||||
|
info[0].replace(File.separatorChar, '/');
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composes a triplet of [class, name, action] into the path that
|
* Composes a triplet of [class, name, action] into the path that should be supplied to the
|
||||||
* should be supplied to the JarEntry that contains the associated
|
* JarEntry that contains the associated image data.
|
||||||
* image data.
|
|
||||||
*/
|
*/
|
||||||
protected String composePath (String[] info, String extension)
|
protected String composePath (String[] info, String extension)
|
||||||
{
|
{
|
||||||
return (info[0] + File.separator + info[1] +
|
return (info[0] + "/" + info[1] + "/" + info[2] + extension);
|
||||||
File.separator + info[2] + extension);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ensureSet (Object value, String errmsg)
|
protected void ensureSet (Object value, String errmsg)
|
||||||
|
|||||||
Reference in New Issue
Block a user