Author: adrianc
Date: Thu May 7 06:30:59 2009
New Revision: 772513
URL:
http://svn.apache.org/viewvc?rev=772513&view=revLog:
Improved FileUtil.getFile(...) method - now supports component:// paths.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java?rev=772513&r1=772512&r2=772513&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java Thu May 7 06:30:59 2009
@@ -30,12 +30,15 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
+import java.net.MalformedURLException;
import java.util.List;
import java.util.Set;
import javolution.util.FastList;
import javolution.util.FastSet;
+import org.ofbiz.base.location.ComponentLocationResolver;
+
import org.apache.commons.io.FileUtils;
/**
@@ -51,6 +54,14 @@
}
public static File getFile(File root, String path) {
+ if (path.startsWith("component://")) {
+ try {
+ path = ComponentLocationResolver.getBaseLocation(path).toString();
+ } catch (MalformedURLException e) {
+ Debug.logError(e, module);
+ return null;
+ }
+ }
String fileNameSeparator = ("\\".equals(File.separator)? "\\" + File.separator: File.separator);
return new File(root, path.replaceAll("/+|\\\\+", fileNameSeparator));
}