[Arakhnę-Dev] [187] * Fixing Windows Native path support.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 187
Author:   galland
Date:     2010-09-28 20:53:31 +0200 (Tue, 28 Sep 2010)
Log Message:
-----------
* Fixing Windows Native path support.

Modified Paths:
--------------
    trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
    trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java

Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2010-09-21 15:53:05 UTC (rev 186)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2010-09-28 18:53:31 UTC (rev 187)
@@ -49,11 +49,33 @@
 
 	static {
 		URLHandlerUtil.installArakhneHandlers();
+		
+		String validChars = "[^\\\\/:*?\"<>|]"; //$NON-NLS-1$
+		String bslashChar = "\\\\"; //$NON-NLS-1$
+		
+		StringBuffer pattern = new StringBuffer();
+		pattern.append("^"); //$NON-NLS-1$
+		pattern.append("(([a-zA-Z]:"); //$NON-NLS-1$
+		pattern.append(validChars);
+		pattern.append("*)|("); //$NON-NLS-1$
+		pattern.append(validChars);
+		pattern.append("+"); //$NON-NLS-1$
+		pattern.append(bslashChar);
+		pattern.append(validChars);
+		pattern.append("+)|("); //$NON-NLS-1$
+		pattern.append(bslashChar);
+		pattern.append("))?("); //$NON-NLS-1$
+		pattern.append(bslashChar);
+		pattern.append(validChars);
+		pattern.append("*)*"); //$NON-NLS-1$
+		pattern.append("$"); //$NON-NLS-1$
+		//"^([A-Za-z]:)?([^\\\\/:*?\"<>|]*\\\\)*[^\\\\/:*?\"<>|]*$"; //$NON-NLS-1$
+		WINDOW_NATIVE_FILENAME_PATTERN = pattern.toString();
 	}
 	
 	/** Regular expression pattern which corresponds to Windows native filename.
 	 */
-	private static final String WINDOW_NATIVE_FILENAME_PATTERN = "^([A-Za-z]:)?([^\\\\/:*?\"<>|]*\\\\)*[^\\\\/:*?\"<>|]*$"; //$NON-NLS-1$
+	private static final String WINDOW_NATIVE_FILENAME_PATTERN;
 	
 	/** Character used to specify a file extension.
 	 */
@@ -326,6 +348,7 @@
 	 */
 	public static String largeBasename(String filename) {
 		if (filename==null) return null;
+		assert(!isWindowsNativeFilename(filename));
 		int end = filename.length();
 		int idx;
 		do {
@@ -359,6 +382,7 @@
 	public static String largeBasename(URL filename) {
 		if (filename==null) return null;
 		String fullPath = filename.getPath();
+		assert(!isWindowsNativeFilename(fullPath));
 		int idx;
 		int end = fullPath.length();
 		do {
@@ -385,6 +409,7 @@
 	 */
 	public static String basename(String filename) {
 		if (filename==null) return null;
+		assert(!isWindowsNativeFilename(filename));
 		int end = filename.length();
 		int idx;
 		do {
@@ -435,6 +460,7 @@
 	public static String basename(URL filename) {
 		if (filename==null) return null;
 		String largeBasename = filename.getPath();
+		assert(!isWindowsNativeFilename(largeBasename));
 		int end = largeBasename.length();
 		int idx;
 		do {
@@ -465,6 +491,7 @@
 	 */
 	public static String shortBasename(String filename) {
 		if (filename==null) return null;
+		assert(!isWindowsNativeFilename(filename));
 		int idx;
 		int end = filename.length();
 		do {
@@ -508,6 +535,7 @@
 	public static String shortBasename(URL filename) {
 		if (filename==null) return null;
 		String largeBasename = filename.getPath();
+		assert(!isWindowsNativeFilename(largeBasename));
 		int idx;
 		int end = largeBasename.length();
 		do {
@@ -1245,8 +1273,20 @@
 	 * @param url is the URL to convert.
 	 * @return the file.
 	 * @throws IllegalArgumentException is the URL was malformed.
+	 * @deprecated {@link #convertURLToFile(URL)}
 	 */
+	@Deprecated
 	public static File convertUrlToFile(URL url) {
+		return convertURLToFile(url);
+	}
+	
+	/** Convert an URL which represents a local file into a File.
+	 * 
+	 * @param url is the URL to convert.
+	 * @return the file.
+	 * @throws IllegalArgumentException is the URL was malformed.
+	 */
+	public static File convertURLToFile(URL url) {
 		URI uri;
 		try {
 			// this is the step that can fail, and so
@@ -1317,7 +1357,7 @@
 	 * @see Resources#getResource(String)
 	 */
 	public static URL convertStringToUrl(String urlDescription, boolean allowResourceSearch) {
-		return convertStringToUrl(urlDescription, allowResourceSearch, true);
+		return convertStringToURL(urlDescription, allowResourceSearch, true);
 	}
 
 	/** Convert a string to an URL according to several rules.
@@ -1345,11 +1385,48 @@
 	 * @return the URL.
 	 * @throws IllegalArgumentException is the string could not be formatted to URL.
 	 * @see Resources#getResource(String)
+	 * @deprecated {@link #convertStringToURL(String, boolean, boolean)}
 	 */
+	@Deprecated
 	public static URL convertStringToUrl(String urlDescription, boolean allowResourceSearch, boolean repliesFileURL) {
+		return convertStringToURL(urlDescription, allowResourceSearch, repliesFileURL);
+	}
+	
+	/** Convert a string to an URL according to several rules.
+	 * <p>
+	 * The rules are (the first succeeded is replied):
+	 * <ul>
+	 * <li>if <var>urlDescription</var> is <code>null</code> or empty, return <code>null</code>;</li>
+	 * <li>try to build an {@link URL} with <var>urlDescription</var> as parameter;</li>
+	 * <li>if <var>allowResourceSearch</var> is <code>true</code> and 
+	 * <var>urlDescription</var> starts with {@code "resource:"}, call
+	 * {@link Resources#getResource(String)} with the rest of the string as parameter;</li>
+	 * <li>if <var>allowResourceSearch</var> is <code>true</code>, call
+	 * {@link Resources#getResource(String)} with the <var>urlDescription</var> as
+	 * parameter;</li>
+	 * <li>if <var>repliesFileURL</var> is <code>true</code> and 
+	 * assuming that the <var>urlDescription</var> is
+	 * a filename, call {@link File#toURI()} to retreive an URI and then
+	 * {@link URI#toURL()};</li>
+	 * <li>If everything else failed, return <code>null</code>.</li>
+	 * </ul>
+	 * 
+	 * @param urlDescription is a string which is describing an URL.
+	 * @param allowResourceSearch indicates if the convertion must take into account the Java resources.
+	 * @param repliesFileURL indicates if urlDescription is allowed to be a filename.
+	 * @return the URL.
+	 * @throws IllegalArgumentException is the string could not be formatted to URL.
+	 * @see Resources#getResource(String)
+	 */
+	public static URL convertStringToURL(String urlDescription, boolean allowResourceSearch, boolean repliesFileURL) {
 		URL url = null;
 
 		if (urlDescription!=null && urlDescription.length()>0)  {
+			
+			if (isWindowsNativeFilename(urlDescription)) {
+				File f = normalizeWindowsNativeFilename(urlDescription);
+				if (f!=null) return convertFileToURL(f);
+			}
 
 			if (URISchemeType.RESOURCE.isScheme(urlDescription)) {
 				if (allowResourceSearch) {
@@ -1896,7 +1973,7 @@
 		if (fn==null || fn.length()==0) return false;
 		Pattern pattern = Pattern.compile(WINDOW_NATIVE_FILENAME_PATTERN);
 		Matcher matcher = pattern.matcher(fn);
-		return matcher.find();
+		return matcher.matches();
 	}
 	
 	/** Normalize the given string contains a Windows&reg; native long filename
@@ -1945,7 +2022,13 @@
 	public static URL convertFileToURL(File file) {
 		if (file==null) return null;
 		try {
-			return toShortestURL(file.toURI().toURL());
+			File f = file;
+			if (isWindowsNativeFilename(file.toString())) {
+				f = normalizeWindowsNativeFilename(file.toString());
+				if (f==null) f = file;
+			}
+			URL url = f.toURI().toURL();
+			return toShortestURL(url);
 		}
 		catch (MalformedURLException e) {
 			return null;

Modified: trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
===================================================================
--- trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java	2010-09-21 15:53:05 UTC (rev 186)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java	2010-09-28 18:53:31 UTC (rev 187)
@@ -108,10 +108,117 @@
 		LibraryLoader.setEnable(this.oldLibraryLoaderState);
 		super.tearDown();
 	}
+	
+	/**
+	 */
+	public void testIsWindowNativeFilename() {
+		assertFalse(FileSystem.isWindowsNativeFilename("D:/vivus_test/export dae/yup/terrain_physx.dae")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("/vivus_test/export dae/yup/terrain_physx.dae")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("/")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("\\\\")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("\\\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("\\\\\\\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$
 
+		assertTrue(FileSystem.isWindowsNativeFilename("file:C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file:C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file:a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file:\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+
+		assertTrue(FileSystem.isWindowsNativeFilename("C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("a\\b\\c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+
+		assertFalse(FileSystem.isWindowsNativeFilename("file:C:/a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file://C:/a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:C:a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file://C:a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:/a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:///a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file://a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file://host/a/b/c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:////host/a/b/c.txt")); //$NON-NLS-1$
+
+		assertTrue(FileSystem.isWindowsNativeFilename("C:c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file:C:c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file:c.txt")); //$NON-NLS-1$
+		assertTrue(FileSystem.isWindowsNativeFilename("file://C:c.txt")); //$NON-NLS-1$
+		assertFalse(FileSystem.isWindowsNativeFilename("file://c.txt")); //$NON-NLS-1$
+	}
+
 	/**
 	 */
-	public void tetIsJarURLURL() {
+	public void testNormalizeWindowNativeFilename() {
+		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+
+		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("C:\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("\\a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("a\\b\\c.txt")); //$NON-NLS-1$
+		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
+
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:C:/a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file://C:/a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:C:a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file://C:a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:/a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:///a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file://a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file://host/a/b/c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:////host/a/b/c.txt")); //$NON-NLS-1$
+
+		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("C:c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file:C:c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file:c.txt")); //$NON-NLS-1$
+		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
+				FileSystem.normalizeWindowsNativeFilename("file://C:c.txt")); //$NON-NLS-1$
+		assertNull(FileSystem.normalizeWindowsNativeFilename("file://c.txt")); //$NON-NLS-1$
+	}
+	
+	/**
+	 */
+	public void testIsJarURLURL() {
 		assertFalse(FileSystem.isJarURL(u1));
 		assertFalse(FileSystem.isJarURL(u2));
 		assertFalse(FileSystem.isJarURL(u3));
@@ -203,6 +310,21 @@
 		assertEquals("home", FileSystem.largeBasename(f2.getAbsolutePath())); //$NON-NLS-1$
 		assertEquals("a.b.c", FileSystem.largeBasename("file:///a.b.c/")); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("file:", FileSystem.largeBasename("file://")); //$NON-NLS-1$ //$NON-NLS-2$
+
+		try {
+			assertEquals("terrain_physx.dae", FileSystem.largeBasename("D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
+		try {
+			assertEquals("terrain_physx.dae", FileSystem.largeBasename("file:D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -224,6 +346,15 @@
 		assertEquals("file.x.z.z", FileSystem.largeBasename(u7)); //$NON-NLS-1$
 		assertEquals("a.b.c", FileSystem.largeBasename(new URL("file:///a.b.c/"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("", FileSystem.largeBasename(new URL("file://"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+		URL url = new URL("file", "", "D:\\vivus_test\\export dae\\yup\\terrain_physx.dae"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		try {
+			assertEquals("terrain_physx.dae", FileSystem.largeBasename(url)); //$NON-NLS-1$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -233,6 +364,21 @@
 		assertEquals("home", FileSystem.basename(f2.getAbsolutePath())); //$NON-NLS-1$
 		assertEquals("a.b", FileSystem.basename("/a.b.c/")); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("", FileSystem.basename("")); //$NON-NLS-1$ //$NON-NLS-2$
+
+		try {
+			assertEquals("terrain_physx", FileSystem.basename("D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
+		try {
+			assertEquals("terrain_physx", FileSystem.basename("file:D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -254,6 +400,15 @@
 		assertEquals("file.x.z", FileSystem.basename(u7)); //$NON-NLS-1$
 		assertEquals("a.b", FileSystem.basename(new URL("file:///a.b.c/"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("", FileSystem.basename(new URL("file://"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+		URL url = new URL("file", "", "D:\\vivus_test\\export dae\\yup\\terrain_physx.dae"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		try {
+			assertEquals("terrain_physx", FileSystem.basename(url)); //$NON-NLS-1$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -263,6 +418,21 @@
 		assertEquals("home", FileSystem.shortBasename(f2.getAbsolutePath())); //$NON-NLS-1$
 		assertEquals("a", FileSystem.shortBasename("/a.b.c/")); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("", FileSystem.shortBasename("")); //$NON-NLS-1$ //$NON-NLS-2$
+
+		try {
+			assertEquals("terrain_physx", FileSystem.shortBasename("D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
+		try {
+			assertEquals("terrain_physx", FileSystem.shortBasename("file:D:\\vivus_test\\export dae\\yup\\terrain_physx.dae")); //$NON-NLS-1$ //$NON-NLS-2$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -284,6 +454,15 @@
 		assertEquals("file", FileSystem.shortBasename(u7)); //$NON-NLS-1$
 		assertEquals("a", FileSystem.shortBasename(new URL("file:///a.b.c/"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals("", FileSystem.shortBasename(new URL("file://"))); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		URL url = new URL("file", "", "D:\\vivus_test\\export dae\\yup\\terrain_physx.dae"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		try {
+			assertEquals("terrain_physx", FileSystem.shortBasename(url)); //$NON-NLS-1$
+			fail("expecting assertion failure"); //$NON-NLS-1$
+		}
+		catch(AssertionError _) {
+			//
+		}
 	}
 
 	/**
@@ -580,7 +759,7 @@
 		rr = FileSystem.convertStringToUrl("file://marbre.jpg", false); //$NON-NLS-1$
 		assertNotNull(rr);
 		assertEquals("file", rr.getProtocol()); //$NON-NLS-1$
-		assertEquals("", rr.getAuthority()); //$NON-NLS-1$
+		assertEquals("", rr.getAuthority()); //$NON-NLS-1$s
 		assertEquals("", rr.getHost()); //$NON-NLS-1$
 		assertNull(rr.getQuery());
 		assertEquals("marbre.jpg", rr.getPath()); //$NON-NLS-1$
@@ -646,10 +825,10 @@
 	 */
 	public void testConvertUrlToFile() throws Exception {
 		assertEquals(f1,
-				 FileSystem.convertUrlToFile(new URL("file:"+f1.getAbsolutePath()))); //$NON-NLS-1$
+				 FileSystem.convertURLToFile(new URL("file:"+f1.getAbsolutePath()))); //$NON-NLS-1$
 
 		try {
-			FileSystem.convertUrlToFile(new URL("http://www.arakhne.org";)); //$NON-NLS-1$
+			FileSystem.convertURLToFile(new URL("http://www.arakhne.org";)); //$NON-NLS-1$
 			fail("not a file URL"); //$NON-NLS-1$
 		}
 		catch(IllegalArgumentException _) {
@@ -657,16 +836,16 @@
 		}
 		
 		assertEquals(new File("toto").getCanonicalPath(), //$NON-NLS-1$
-				 FileSystem.convertUrlToFile(new URL("file:./toto")).getCanonicalPath()); //$NON-NLS-1$
+				 FileSystem.convertURLToFile(new URL("file:./toto")).getCanonicalPath()); //$NON-NLS-1$
 
 		assertEquals(new File("toto").getCanonicalPath(), //$NON-NLS-1$
-				 FileSystem.convertUrlToFile(new URL("file:toto")).getCanonicalPath()); //$NON-NLS-1$
+				 FileSystem.convertURLToFile(new URL("file:toto")).getCanonicalPath()); //$NON-NLS-1$
 
 		assertEquals(new File("toto").getCanonicalPath(), //$NON-NLS-1$
-				 FileSystem.convertUrlToFile(new URL("file:./abs/../toto")).getCanonicalPath()); //$NON-NLS-1$
+				 FileSystem.convertURLToFile(new URL("file:./abs/../toto")).getCanonicalPath()); //$NON-NLS-1$
 
 		assertEquals(new File("/toto").getCanonicalPath(), //$NON-NLS-1$
-				 FileSystem.convertUrlToFile(new URL("file:/toto")).getCanonicalPath()); //$NON-NLS-1$
+				 FileSystem.convertURLToFile(new URL("file:/toto")).getCanonicalPath()); //$NON-NLS-1$
 	}
 	
 	/**
@@ -1007,108 +1186,6 @@
 	}
 	
 	/**
-	 */
-	public void testIsWindowNativeFilename() {
-		assertTrue(FileSystem.isWindowsNativeFilename("file:C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-
-		assertTrue(FileSystem.isWindowsNativeFilename("C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("a\\b\\c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-
-		assertFalse(FileSystem.isWindowsNativeFilename("file:C:/a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file://C:/a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file:C:a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file://C:a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file:/a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file:///a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file:a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file://a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file://host/a/b/c.txt")); //$NON-NLS-1$
-		assertFalse(FileSystem.isWindowsNativeFilename("file:////host/a/b/c.txt")); //$NON-NLS-1$
-
-		assertTrue(FileSystem.isWindowsNativeFilename("C:c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:C:c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file:c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://C:c.txt")); //$NON-NLS-1$
-		assertTrue(FileSystem.isWindowsNativeFilename("file://c.txt")); //$NON-NLS-1$
-	}
-
-	/**
-	 */
-	public void testNormalizeWindowNativeFilename() {
-		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-
-		assertEquals(new File("C:/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("C:\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://C:a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("\\a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("a\\b\\c.txt")); //$NON-NLS-1$
-		assertEquals(new File("//host/a/b/c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("\\\\host\\a\\b\\c.txt")); //$NON-NLS-1$
-
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:C:/a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file://C:/a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:C:a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file://C:a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:/a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:///a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file://a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file://host/a/b/c.txt")); //$NON-NLS-1$
-		assertNull(FileSystem.normalizeWindowsNativeFilename("file:////host/a/b/c.txt")); //$NON-NLS-1$
-
-		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("C:c.txt")); //$NON-NLS-1$
-		assertEquals(new File("c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:C:c.txt")); //$NON-NLS-1$
-		assertEquals(new File("c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file:c.txt")); //$NON-NLS-1$
-		assertEquals(new File("C:c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://C:c.txt")); //$NON-NLS-1$
-		assertEquals(new File("c.txt"), //$NON-NLS-1$
-				FileSystem.normalizeWindowsNativeFilename("file://c.txt")); //$NON-NLS-1$
-	}
-	
-	/**
 	 * @throws Exception
 	 */
 	public void testConvertFileToURLFile() throws Exception {
@@ -1118,7 +1195,7 @@
 			URL u1 = f1.toURI().toURL();
 			URL u2 = Resources.getResource("org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
 			URL u2e = new URL("resource:org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
-			File f2 = FileSystem.convertUrlToFile(u2);
+			File f2 = FileSystem.convertURLToFile(u2);
 			
 			URL actual;
 			


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/