Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/org/sugarj/common/FileCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void main(String[] args) {
}

public final static boolean DO_DELETE = true;

public final static String FORWARD_SLASH = "/";
public final static String TMP_DIR;
static {
try {
Expand Down Expand Up @@ -469,13 +469,12 @@ public static File createDir(File dir, int hash) throws IOException {
*/
public static String toCygwinPath(String filepath) {
// XXX hacky

if (System.getProperty("os.name").toLowerCase().contains("win")) {
filepath = filepath.replace("\\", "/");
filepath = filepath.replace("/C:/", "/cygdrive/C/");
filepath = filepath.replace("C:/", "/cygdrive/C/");
}

return filepath;
}

Expand All @@ -490,7 +489,6 @@ public static String toWindowsPath(String filepath) {
filepath = filepath.replace("/C:", "C:");
filepath = filepath.replace("/", "\\");
}

return filepath;
}

Expand Down Expand Up @@ -797,7 +795,7 @@ public static java.nio.file.Path getRessourcePath(URL url) {

// have we found the class file?
try {
return Paths.get(path);
return Paths.get(trimFront(path));
} catch (InvalidPathException e) {
return null;
}
Expand Down Expand Up @@ -833,4 +831,12 @@ public static void unpackJarfile(File outdir, File jar) throws IOException {
}
}
}

public static String trimFront(String path) {
if (System.getProperty("os.name").toLowerCase().contains("win")) {
while (path.startsWith(FORWARD_SLASH))
path = path.substring(1, path.length());
}
return path;
}
}