Thanks Marco and Jacques for this fix.
However let's consider this a quick fix that needs to be cleaned up: I see several formatting issues and also the name of the method could be enhanced (if we really need a new method...). Well... don't worry about it, I have already fixed the formal issues in rev. 682657 Jacopo On Aug 5, 2008, at 11:36 AM, [hidden email] wrote: > Author: jleroux > Date: Tue Aug 5 02:36:52 2008 > New Revision: 682652 > > URL: http://svn.apache.org/viewvc?rev=682652&view=rev > Log: > A patch from Marco Ruocco solving an issue on Windows : > File.separator in Windows system is "\", that is, also, the first > character of an escape sequence. So the replaceAll method expects > another char after that. > > Modified: > ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ > FileUtil.java > > Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ > FileUtil.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/FileUtil.java?rev=682652&r1=682651&r2=682652&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ > FileUtil.java (original) > +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ > FileUtil.java Tue Aug 5 02:36:52 2008 > @@ -46,12 +46,24 @@ > > public static final String module = FileUtil.class.getName(); > > + public static String escapeSeparator( String separator ) > + { > + if( "\\".equals( separator ) ) > + { > + return "\\" + separator; > + } > + else > + { > + return separator; > + } > + } > + > public static File getFile(String path) { > - return new File(path.replaceAll("/+|\\\\+", File.separator)); > + return new File(path.replaceAll("/+|\\\\+", > escapeSeparator(File.separator))); > } > > public static File getFile(File root, String path) { > - return new File(root, path.replaceAll("/+|\\\\+", > File.separator)); > + return new File(root, path.replaceAll("/+|\\\\+", > escapeSeparator(File.separator))); > } > > public static void writeString(String fileName, String s) throws > IOException { > > smime.p7s (3K) Download Attachment |
Administrator
|
Thanks Jacopo,
I was not really available when I did the commit so did it in a hurry. Updated to r682657, nothing more to do :o) Jacques From: "Jacopo Cappellato" <[hidden email]> > Thanks Marco and Jacques for this fix. > However let's consider this a quick fix that needs to be cleaned up: I see several formatting issues and also the name of the > method could be enhanced (if we really need a new method...). > Well... don't worry about it, I have already fixed the formal issues in rev. 682657 > > Jacopo > > > On Aug 5, 2008, at 11:36 AM, [hidden email] wrote: > >> Author: jleroux >> Date: Tue Aug 5 02:36:52 2008 >> New Revision: 682652 >> >> URL: http://svn.apache.org/viewvc?rev=682652&view=rev >> Log: >> A patch from Marco Ruocco solving an issue on Windows : File.separator in Windows system is "\", that is, also, the first >> character of an escape sequence. So the replaceAll method expects another char after that. >> >> Modified: >> ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ FileUtil.java >> >> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ FileUtil.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/FileUtil.java?rev=682652&r1=682651&r2=682652&view=diff >> = = = = = = = = ====================================================================== >> --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ FileUtil.java (original) >> +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ FileUtil.java Tue Aug 5 02:36:52 2008 >> @@ -46,12 +46,24 @@ >> >> public static final String module = FileUtil.class.getName(); >> >> + public static String escapeSeparator( String separator ) >> + { >> + if( "\\".equals( separator ) ) >> + { >> + return "\\" + separator; >> + } >> + else >> + { >> + return separator; >> + } >> + } >> + >> public static File getFile(String path) { >> - return new File(path.replaceAll("/+|\\\\+", File.separator)); >> + return new File(path.replaceAll("/+|\\\\+", escapeSeparator(File.separator))); >> } >> >> public static File getFile(File root, String path) { >> - return new File(root, path.replaceAll("/+|\\\\+", File.separator)); >> + return new File(root, path.replaceAll("/+|\\\\+", escapeSeparator(File.separator))); >> } >> >> public static void writeString(String fileName, String s) throws IOException { >> >> > > |
Free forum by Nabble | Edit this page |