Skip to content

Commit 3224abe

Browse files
author
Nguyen The Tuyen
committed
CRASH-234 Cannot start crash 1.3.1 on windows 7
1 parent d36266f commit 3224abe

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

shell/src/main/java/org/crsh/standalone/CRaSH.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,15 @@ public void main(
227227
if (buffer.length() > 0) {
228228
buffer.append(' ');
229229
}
230-
buffer.append(file.getCanonicalPath());
230+
String fileName = file.getCanonicalPath();
231+
if(fileName.charAt(0) != '/' && fileName.charAt(1) == ':') {
232+
// On window, the value of Class-Path in Manifest file must in form: /C:/path/lib/abc.jar
233+
fileName = fileName.replace(File.separatorChar, '/');
234+
buffer.append("/").append(fileName);
235+
236+
} else {
237+
buffer.append(file.getCanonicalPath());
238+
}
231239
}
232240
}
233241

shell/src/main/java/org/crsh/vfs/Path.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.crsh.util.BaseIterator;
2323

24+
import java.io.File;
2425
import java.util.Iterator;
2526
import java.util.NoSuchElementException;
2627

@@ -79,7 +80,7 @@ public static Path get(String s) {
7980
//
8081
boolean dir;
8182
int end;
82-
if (s.charAt(s.length() - 1) == '/') {
83+
if (s.charAt(s.length() - 1) == '/' || s.charAt(s.length() - 1) == File.separatorChar) {
8384
dir = true;
8485
end = s.length() - 1;
8586
} else {
@@ -96,6 +97,8 @@ public static Path get(String s) {
9697

9798
private static String[] parseNames(final String s, final int prev, int end, final int count) {
9899
int next = s.indexOf('/', prev);
100+
if (next == -1) next = s.indexOf(File.separatorChar, prev);
101+
99102
if (next == -1 || next > end) {
100103
if (prev < end) {
101104
String[] ret = new String[count + 1];

shell/src/main/java/org/crsh/vfs/spi/file/FileMountFactory.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,22 @@ public FileMountFactory(File root) throws IOException {
6060
@Override
6161
public Mount<File> create(Path path) throws IOException {
6262
File file = path.isAbsolute() ? absoluteRoot : root;
63-
for (String name : path) {
64-
file = new File(file, name);
63+
64+
for (int i = 0; i < path.getSize(); i++) {
65+
String name = path.nameAt(i);
66+
if(i == 0 && isWindow() && name.length() == 2 && name.charAt(1) == ':') {
67+
file = new File(name + File.separatorChar);
68+
} else {
69+
file = new File(file, name);
70+
}
6571
}
72+
6673
// Always use absolute path here
6774
return new Mount<File>(new FileDriver(file), "file:" + file.getAbsolutePath());
6875
}
76+
77+
private static String OS = System.getProperty("os.name").toLowerCase();
78+
private static boolean isWindow() {
79+
return (OS.indexOf("win") >= 0);
80+
}
6981
}

0 commit comments

Comments
 (0)