Title: [1393] trunk/web/web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java: JBEHAVE-195: Use Commons-IO FilenameUtils.getName(path) to extract file name in a platform-independent way
Revision
1393
Author
mauro
Date
2009-12-03 05:50:11 -0600 (Thu, 03 Dec 2009)

Log Message

JBEHAVE-195:  Use Commons-IO FilenameUtils.getName(path) to extract file name in a platform-independent way

Modified Paths

Diff

Modified: trunk/web/web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java (1392 => 1393)

--- trunk/web/web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java	2009-11-26 09:01:43 UTC (rev 1392)
+++ trunk/web/web-io/src/main/java/org/jbehave/web/io/ArchivingFileManager.java	2009-12-03 11:50:11 UTC (rev 1393)
@@ -9,6 +9,7 @@
 import java.util.List;
 
 import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.io.FilenameUtils;
 import org.jbehave.web.io.ZipFileArchiver.FileUnarchiveFailedException;
 
 /**
@@ -125,10 +126,13 @@
 		return file;
 	}
 
-	private String fileName(FileItem item) {
-		File file = new File(item.getName());
-		return file.getName();
-	}
+    private String fileName(FileItem item) {
+        // FileItem.getName() may return the full path, depending on the client
+        // (e.g. IE or Opera)
+        // FilenameUtils.getName(path) extracts file name whatever the path
+        // separator (Unix or Windows)
+        return FilenameUtils.getName(item.getName());
+    }
 
 	@SuppressWarnings("serial")
 	public static final class FileItemNameMissingException extends


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to