From 2f7474f7004b8180beb3a2661e62cf4dc7f6cae3 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 7 Dec 2010 01:06:11 +0000 Subject: [PATCH] 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 --- .../bundle/tools/ComponentBundlerTask.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java b/src/main/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java index 7820c2e8..8777cbc4 100644 --- a/src/main/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java +++ b/src/main/java/com/threerings/cast/bundle/tools/ComponentBundlerTask.java @@ -383,30 +383,26 @@ public class ComponentBundlerTask extends Task { // first strip off the root if (!path.startsWith(_root)) { - throw new BuildException("Can't bundle images outside the " + - "root directory [root=" + _root + - ", path=" + path + "]."); + throw new BuildException("Can't bundle images outside the root directory " + + "[root=" + _root + ", path=" + path + "]."); } path = path.substring(_root.length()); - // strip off any preceding slash - if (path.startsWith("/")) { + // strip off any preceding file separator + if (path.startsWith(File.separator)) { path = path.substring(1); } // now strip off the file extension if (!path.endsWith(BundleUtil.IMAGE_EXTENSION)) { - throw new BuildException("Can't bundle malformed image file " + - "[path=" + path + "]."); + throw new BuildException("Can't bundle malformed image file [path=" + path + "]."); } - path = path.substring(0, path.length() - - BundleUtil.IMAGE_EXTENSION.length()); + path = path.substring(0, path.length() - BundleUtil.IMAGE_EXTENSION.length()); - // now decompose the path; the component type and action must - // always be a single string but the class can span multiple - // directories for easier component organization; thus - // "male/head/goatee/standing" will be parsed as [class=male/head, - // type=goatee, action=standing] + // now decompose the path; the component type and action must always be a single string but + // the class can span multiple directories for easier component organization; thus + // "male/head/goatee/standing" will be parsed as + // [class=male/head, type=goatee, action=standing] String malmsg = "Can't decode malformed image path: '" + path + "'"; String[] info = new String[3]; int lsidx = path.lastIndexOf(File.separator); @@ -420,18 +416,19 @@ public class ComponentBundlerTask extends Task } info[1] = path.substring(slsidx+1, lsidx); 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; } /** - * Composes a triplet of [class, name, action] into the path that - * should be supplied to the JarEntry that contains the associated - * image data. + * Composes a triplet of [class, name, action] into the path that should be supplied to the + * JarEntry that contains the associated image data. */ protected String composePath (String[] info, String extension) { - return (info[0] + File.separator + info[1] + - File.separator + info[2] + extension); + return (info[0] + "/" + info[1] + "/" + info[2] + extension); } protected void ensureSet (Object value, String errmsg)