Skip to content

Commit 0252623

Browse files
committed
Clear now tells you when it cant delete
1 parent 810b3a2 commit 0252623

5 files changed

Lines changed: 38 additions & 17 deletions

File tree

‎koans/app/config/i18n/messages_en.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ClassArg.success=
7878

7979
Clear.args= -clear
8080
Clear.description=Clears compiled artifacts and stored file system timestamps.
81-
Clear.error=Unable to delete filesystem_hashes.dat or bin directory.
81+
Clear.error=Unable to delete filesystem_hashes.dat or application data or class directory.
8282
Clear.success=Classes and file system timestamps deleted successfully.
8383

8484
Debug.args= -debug, debug, d

‎koans/app/lib/koans.jar‎

812 Bytes
Binary file not shown.

‎koans/run.bat‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ javac -version
1010
if ERRORLEVEL 3 goto no_javac
1111
java -version
1212
if ERRORLEVEL 1 goto no_java
13-
mkdir "%~dp0\app\data"
14-
mkdir "%~dp0\app\bin"
1513
cls
16-
echo "%~dp0app\bin%CLASSPATH%"
1714
java -Dapplication.basedir="%~dp0"" -classpath %CLASSPATH% com.sandwich.koan.runner.AppLauncher %1 %2 %3 %4 %5 %6 %7 %8 %9
1815

1916
goto end

‎koans/run.sh‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
#!/bin/bash
12
DIR="$( cd -P "$( dirname "$0" )" && pwd )"
2-
mkdir -p "$DIR"/app/data
3-
mkdir -p "$DIR"/app/bin
3+
mkdir -p "$DIR""/app/data"
4+
mkdir -p "$DIR""/app/bin"
45
exitOnError()
56
{
6-
rc=$?
7-
if [[ $rc != 0 ]] ; then
8-
echo ${1}' is missing from your PATH.'
9-
exit $rc
10-
fi
7+
rc=$?
8+
if [[ $rc != 0 ]] ; then
9+
echo ${1}' is missing from your PATH.'
10+
exit $rc
11+
fi
1112
}
1213

1314
buildClasspath()
1415
{
1516
appDir=$1
1617
classpath=$appDir/bin
17-
IFS=$'\n'
18+
IFS=$'\n'
1819

19-
for jar in $appDir/lib/*; do
20+
for jar in $appDir/lib/*
21+
do
2022
classpath=$classpath:$jar
2123
done
2224
}
@@ -25,4 +27,5 @@ exitOnError 'javac'
2527
java -version > /dev/null 2>&1
2628
exitOnError 'java'
2729
buildClasspath "$DIR"/app
28-
java -Dapplication.basedir=\"$DIR\" -classpath \"$classpath\" com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
30+
cmd="java -Dapplication.basedir=\"$DIR\" -classpath \"$classpath\" com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9""
31+
eval $cmd
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
package com.sandwich.koan.cmdline.behavior;
22

33
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.List;
47

8+
import com.sandwich.koan.util.ApplicationUtils;
59
import com.sandwich.util.io.directories.DirectoryManager;
610

711
public class Clear extends AbstractArgumentBehavior {
812

13+
List<String> files = Arrays.asList(
14+
DirectoryManager.getDataFile(),
15+
DirectoryManager.getBinDir(),
16+
DirectoryManager.getDataDir());
17+
918
public void run(String... values) throws Exception {
10-
new File(DirectoryManager.getDataFile()).delete();
11-
new File(DirectoryManager.getBinDir()).delete();
12-
new File(DirectoryManager.getDataDir()).delete();
19+
List<File> unableToDelete = new ArrayList<File>();
20+
for(String fileName : files){
21+
File file = new File(fileName);
22+
if(file.exists()){
23+
if(file.delete()){
24+
ApplicationUtils.getPresenter().displayMessage(file.getAbsolutePath() + " deleted successfully.");
25+
}else{
26+
unableToDelete.add(file);
27+
ApplicationUtils.getPresenter().displayError(file.getAbsolutePath() + " was NOT DELETED. Please delete manually.");
28+
}
29+
}else{
30+
ApplicationUtils.getPresenter().displayMessage(file.getAbsolutePath() + " does not exist. Skipping.");
31+
}
32+
}
33+
throw new RuntimeException("Unable to delete: "+unableToDelete+" see output for details.");
1334
}
1435

1536
}

0 commit comments

Comments
 (0)