Title: [1342] trunk/web/web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java: Normalise paths to correctly extract relative path.
Revision
1342
Author
mauro
Date
2009-10-15 15:19:37 -0500 (Thu, 15 Oct 2009)

Log Message

Normalise paths to correctly extract relative path.

Modified Paths


Diff

Modified: trunk/web/web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java (1341 => 1342)

--- trunk/web/web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java	2009-10-15 20:00:09 UTC (rev 1341)
+++ trunk/web/web-io/src/main/java/org/jbehave/web/io/ZipFileArchiver.java	2009-10-15 20:19:37 UTC (rev 1342)
@@ -51,9 +51,13 @@
 	}
 
 	public File relativeTo(File file, File directory) {
-		return new File(removeStart(file.getPath(), directory.getPath() + "/"));
+		return new File(removeStart(normalisePath(file.getPath()), normalisePath(directory.getPath()) + "/"));
 	}
 
+	private String normalisePath(String path) {
+		return path.replace('\\', '/');
+	}
+	
 	private void zipEntry(ZipArchiveEntry entry, ArchiveOutputStream out,
 			File file) throws IOException, FileNotFoundException {
 		out.putArchiveEntry(entry);
@@ -95,7 +99,7 @@
 
 	public List<File> listContent(File file) {
 		List<File> content = new ArrayList<File>();
-		content.add(normalisePath(file));
+		content.add(file);
 		if (file.isDirectory()) {
 			for (File child : file.listFiles()) {
 				content.addAll(listContent(child));
@@ -104,10 +108,6 @@
 		return content;
 	}
 
-	private File normalisePath(File file) {
-		return new File(file.getPath().replace('\\', '/'));
-	}
-
 	private void unzipEntry(ZipArchiveEntry entry, InputStream in,
 			File directory) throws IOException {
 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to