From: <adr...@us...> - 2010-03-13 18:56:26
|
Revision: 3558 http://reprap.svn.sourceforge.net/reprap/?rev=3558&view=rev Author: adrian-bowyer Date: 2010-03-13 18:55:57 +0000 (Sat, 13 Mar 2010) Log Message: ----------- More fixing of problems caused by / and \ in file paths on Windoze and Linux. Now it turns out that .zip files have those characters embedded in for directory trees, and they have to be undone when a windows-generated rfo is read on Linux... Sigh. Modified Paths: -------------- trunk/reprap/host/src/org/reprap/RFO.java Modified: trunk/reprap/host/src/org/reprap/RFO.java =================================================================== --- trunk/reprap/host/src/org/reprap/RFO.java 2010-03-13 12:29:52 UTC (rev 3557) +++ trunk/reprap/host/src/org/reprap/RFO.java 2010-03-13 18:55:57 UTC (rev 3558) @@ -650,6 +650,33 @@ // .rfo reading /** + * Arrghhh!!!! + */ + private String processSeparators(String is) + { + String result = ""; + for(int i = 0; i < is.length(); i++) + { + if(is.charAt(i) == '\\') + { + if(File.separator.charAt(0) == '/') + result += '/'; + else + result += '\\'; + } else if(is.charAt(i) == '/') + { + if(File.separator.charAt(0) == '\\') + result += '\\'; + else + result += '/'; + } else + result += is.charAt(i); + } + + return result; + } + + /** * This uncompresses the zip that is the rfo file into the temporary directory. */ private void unCompress() @@ -664,7 +691,8 @@ { ZipEntry ze = (ZipEntry)allFiles.nextElement(); InputStream is = rfoFile.getInputStream(ze); - File element = new File(tempDir + ze.getName()); + String fName = processSeparators(ze.getName()); + File element = new File(tempDir + fName); org.reprap.Main.ftd.add(element); FileOutputStream os = new FileOutputStream(element); while((bytesIn = is.read(buffer)) != -1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |