[Arakhnę-Dev] [57] Bug fix: relative filename in URL could not be translated into File. |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 57
Author: galland
Date: 2009-04-18 21:57:06 +0200 (Sat, 18 Apr 2009)
Log Message:
-----------
Bug fix: relative filename in URL could not be translated into File. Fixed by testing if the URI resulting from the translation of the URL has an authority part or not.
Modified Paths:
--------------
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2009-04-18 18:46:16 UTC (rev 56)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2009-04-18 19:57:06 UTC (rev 57)
@@ -26,7 +26,6 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -425,7 +424,16 @@
}
}
- return new File(uri);
+ if ("file".equalsIgnoreCase(uri.getScheme())) { //$NON-NLS-1$
+ String auth = uri.getAuthority();
+ if (auth==null || "".equals(auth)) { //$NON-NLS-1$
+ // absolute filename in URI
+ return new File(uri);
+ }
+ // relative filename in URI, extract it directly
+ return new File(auth+uri.getPath());
+ }
+ throw new IllegalArgumentException("not a file URL: "+url); //$NON-NLS-1$
}
}