[Arakhnę-Dev] [181] * Add current directory at the head of the relative path replied by makeRelativePath ().

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


Revision: 181
Author:   galland
Date:     2010-09-07 21:14:53 +0200 (Tue, 07 Sep 2010)
Log Message:
-----------
* Add current directory at the head of the relative path replied by makeRelativePath().

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-07 17:47:54 UTC (rev 180)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2010-09-07 19:14:53 UTC (rev 181)
@@ -1947,7 +1947,9 @@
 		String[] parts1 = split(dir);
 		String[] parts2 = split(root);
 		
-		return new File(makeRelative(parts1, parts2, filenameToMakeRelative.getName()));
+		String relPath = makeRelative(parts1, parts2, filenameToMakeRelative.getName());
+		
+		return new File(CURRENT_DIRECTORY, relPath);
 	}
 	
 	private static String makeRelative(String[] parts1, String[] parts2, String basename) {

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-07 17:47:54 UTC (rev 180)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java	2010-09-07 19:14:53 UTC (rev 181)
@@ -1128,11 +1128,11 @@
 		root = FileSystem.getUserHomeDirectory();
 		
 		abs = new File(FileSystem.getUserHomeDirectory(), "a"); //$NON-NLS-1$
-		rel = new File("a"); //$NON-NLS-1$
+		rel = new File(FileSystem.CURRENT_DIRECTORY+File.separator+"a"); //$NON-NLS-1$
 		assertEquals(rel, FileSystem.makeRelative(abs, root));
 
 		abs = new File(FileSystem.getUserHomeDirectory(), "a"+File.separator+"b"); //$NON-NLS-1$ //$NON-NLS-2$
-		rel = new File("a","b"); //$NON-NLS-1$ //$NON-NLS-2$
+		rel = new File(FileSystem.CURRENT_DIRECTORY+File.separator+"a","b"); //$NON-NLS-1$ //$NON-NLS-2$
 		assertEquals(rel, FileSystem.makeRelative(abs, root));
 
 		abs = new File("a","b"); //$NON-NLS-1$//$NON-NLS-2$
@@ -1144,8 +1144,9 @@
 		root = new File(FileSystem.getUserHomeDirectory(), "zz"+File.separator+"abc"); //$NON-NLS-1$ //$NON-NLS-2$
 		
 		abs = new File(FileSystem.getUserHomeDirectory(), "a"); //$NON-NLS-1$
-		rel = new File(FileSystem.PARENT_DIRECTORY+File.separator
+		rel = new File(FileSystem.CURRENT_DIRECTORY+File.separator
 				+FileSystem.PARENT_DIRECTORY+File.separator
+				+FileSystem.PARENT_DIRECTORY+File.separator
 				+"a"); //$NON-NLS-1$
 		assertEquals(rel, FileSystem.makeRelative(abs, root));
 
@@ -1154,8 +1155,9 @@
 		root = new File(FileSystem.getUserHomeDirectory(), "zz"+File.separator+"abc"); //$NON-NLS-1$//$NON-NLS-2$
 		
 		abs = new File(FileSystem.getUserHomeDirectory(), "a"+File.separator+"zz"+File.separator+"bc"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
-		rel = new File(FileSystem.PARENT_DIRECTORY+File.separator
+		rel = new File(FileSystem.CURRENT_DIRECTORY+File.separator
 				+FileSystem.PARENT_DIRECTORY+File.separator
+				+FileSystem.PARENT_DIRECTORY+File.separator
 				+"a"+File.separator+"zz"+File.separator+"bc"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
 		assertEquals(rel, FileSystem.makeRelative(abs, root));
 	}


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