Skip to content

Commit

Permalink
can now execute outside script directory in *nix
Browse files Browse the repository at this point in the history
  • Loading branch information
matyb committed Nov 4, 2011
1 parent 81b3d7b commit 938a1bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
21 changes: 16 additions & 5 deletions koans-lib/src/com/sandwich/util/io/directories/DirectorySet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.sandwich.util.io.directories;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;

import com.sandwich.koan.util.ApplicationUtils;

abstract class DirectorySet {

Expand Down Expand Up @@ -39,14 +43,21 @@ public String getDataDir(){
}

private static String createBaseDir() {
File dir = new File(".");
dir = new File(dir.getAbsolutePath().replace("%20", " "));
if (dir.exists()) {
dir = dir.getParentFile();
URL path = DirectorySet.class.getClassLoader().getResource(".");
try {
File dir = new File(path.toURI());
if(ApplicationUtils.isWindows()){
dir = new File(dir.getAbsolutePath().replace("%20", " "));
}
if (dir.exists()) {
dir = dir.getParentFile();
if (dir.exists()) {
dir = dir.getParentFile();
}
}
return dir.getAbsolutePath();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return dir.getAbsolutePath();
}
}
Binary file modified koans/lib/koans.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion koans/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
clear
java -classpath bin:lib/koans.jar com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
java -classpath "$DIR"/bin:"$DIR"/lib/koans.jar com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"

0 comments on commit 938a1bd

Please sign in to comment.