svn commit: r1231539 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1231539 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java

adrianc
Author: adrianc
Date: Sat Jan 14 17:49:01 2012
New Revision: 1231539

URL: http://svn.apache.org/viewvc?rev=1231539&view=rev
Log:
Extracted FileUtil.java's OS-dependent file path conversion to a separate method.

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=1231539&r1=1231538&r2=1231539&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 Sat Jan 14 17:49:01 2012
@@ -62,8 +62,18 @@ public class FileUtil {
                 return null;
             }
         }
-        String fileNameSeparator = ("\\".equals(File.separator)? "\\" + File.separator: File.separator);
-        return new File(root, path.replaceAll("/+|\\\\+", fileNameSeparator));
+        return new File(root, localizePath(path));
+    }
+
+    /**
+     * Converts a file path to one that is compatible with the host operating system.
+     *
+     * @param path The file path to convert.
+     * @return The converted file path.
+     */
+    public static String localizePath(String path) {
+        String fileNameSeparator = ("\\".equals(File.separator) ? "\\" + File.separator : File.separator);
+        return path.replaceAll("/+|\\\\+", fileNameSeparator);
     }
 
     public static void writeString(String fileName, String s) throws IOException {