Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

fixing the UNC path handling in Windows

  • Loading branch information...
commit d5fed53ff19b128b3f89befe0dec37ddc051275f 1 parent ce5f681
@kohsuke authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/main/java/org/jvnet/winp/
17 src/main/java/org/jvnet/winp/
@@ -67,13 +67,22 @@ private static void load() {
filePortion = filePortion.substring(1);
- if(filePortion.startsWith("file:/")) {
- filePortion = filePortion.substring(6);
- if(filePortion.startsWith("//"))
+ if(filePortion.startsWith("file:")) {
+ filePortion = filePortion.substring(5);
+ if(filePortion.startsWith("///")) {
+ // JDK on Unix uses file:/home/kohsuke/abc, whereas
+ // I believe RFC says file:///home/kohsuke/abc/... is correct.
jglick added a note

Either is fine; java.nio.file accepts both but produces the latter in order (I was told) to keep track of whether non-ASCII characters in a path were using an original byte encoding (or something like this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filePortion = filePortion.substring(2);
+ } else
+ if(filePortion.startsWith("//")) {
+ // this indicates file://host/path-in-host format
+ // Windows maps UNC path to this. On Unix, there's no well defined
+ // semantics for this.
+ }
filePortion = URLDecoder.decode(filePortion);
String preferred = System.getProperty(DLL_TARGET);
- File jarFile = new File(preferred != null ? preferred : filePortion);
+ File jarFile = new File(preferred != null ? preferred : filePortion.replace('/',File.separatorChar));
jglick added a note

This is poor style and will probably fail to handle some pathnames. Better is to use java.nio.file when on Java 7; for Java 6 compatibility, use File.<init>(URI) after performing a manual check for UNC paths (file://server/share/path).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
File dllFile = new File(jarFile.getParentFile(),dllName+".dll");
if(!dllFile.exists() || jarFile.lastModified()>dllFile.lastModified()) {
// try to extract from within the jar

0 comments on commit d5fed53

Please sign in to comment.
Something went wrong with that request. Please try again.