Commits

mquigley  committed eded6a0

Conversion to absolute path?

  • Participants
  • Parent commits 2ee6a38
  • Branches default

Comments (0)

Files changed (2)

File src/java/com/quigley/filesystem/FilesystemPath.java

     	this.elements = elements;
     }
 
+    public FilesystemPath toAbsolute() {
+    	FilesystemPath absolutePath = new FilesystemPath(this.asFile().getAbsolutePath());
+    	if(absolutePath.getLast().equals(".")) {
+    		absolutePath = absolutePath.removeLast();
+    	}
+    	return absolutePath;
+    }
+    
     public boolean isAbsolute() {
         return isAbsolute;
     }
-
     public void setAbsolute(boolean absolute) {
         isAbsolute = absolute;
     }

File src/test/com/quigley/filesystem/FilesystemPathTest.java

     	String linkPath = path.navigate(new FilesystemPath("a/d/e"));
     	assertEquals("../d/e", linkPath);
     }
+    
+    @Test
+    public void testToAbsolute1() {
+    	FilesystemPath path = new FilesystemPath(".").toAbsolute();
+    	System.out.println("Absolute: " + path);
+    	path = new FilesystemPath("src/java").toAbsolute();
+    	System.out.println("Absolute: " + path);
+    }
 }