X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2FHaskellHelper.java;h=4e3b2c657400974f8e056a86b5fd82ee34ad6057;hb=78e11871be7fa7677a0e3822b6e08b3beca1c4b7;hp=290d3d7a1130eac31853f539ca4678c31a044ae5;hpb=775a8a55fd36625a5f092e662c61b5825b8b6ab4;p=wix.git diff --git a/src/HaskellHelper.java b/src/HaskellHelper.java index 290d3d7..4e3b2c6 100644 --- a/src/HaskellHelper.java +++ b/src/HaskellHelper.java @@ -1,4 +1,6 @@ -// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license +// Copyright 2008 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. import edu.berkeley.sbp.*; import edu.berkeley.sbp.misc.*; @@ -77,7 +79,33 @@ public class HaskellHelper { process(indir, suffix + File.separatorChar + s, outdir); return; } - if (f.getPath().endsWith(".wix")) { + if (!f.getPath().endsWith(".wix")) { + boolean skip = false; + if (f.getName().equals(".DS_Store")) skip = true; + if (f.getName().endsWith("-")) skip = true; + if (!skip) { + File dest = new File(outdir.getAbsolutePath()+File.separatorChar+suffix); + if (dest.exists() && dest.lastModified()==f.lastModified() && dest.length()==f.length()) { + System.out.println(ANSI.yellow("no change: "+f.getPath())); + return; + } + System.out.println(ANSI.green("copying: "+f.getPath())); + File dest_ = new File(outdir.getAbsolutePath()+File.separatorChar+suffix+"-"); + new File(dest_.getParent()).mkdirs(); + FileOutputStream fos = new FileOutputStream(dest_); + FileInputStream fis = new FileInputStream(f); + byte[] buf = new byte[1024]; + while(true) { + int numread = fis.read(buf, 0, buf.length); + if (numread==-1) break; + fos.write(buf, 0, numread); + } + fos.close(); + fis.close(); + dest_.renameTo(dest); + dest.setLastModified(f.lastModified()); + } + } else { String out = "== " + suffix + " "; while(out.length() < 75) out+="="; System.out.println(ANSI.yellow(out)); @@ -88,6 +116,7 @@ public class HaskellHelper { Class.forName("Main"). getMethod("main", new Class[] { String[].class }). invoke(null, new Object[] { new String[] { f.getAbsolutePath() } }); + try { new File(new File(outPath).getParent()).mkdirs(); PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outPath+"+"))); pw.println(ret); @@ -95,7 +124,6 @@ public class HaskellHelper { pw.close(); File dest = new File(outPath); if (dest.exists()) { - try { Process p = Runtime.getRuntime().exec(new String[] { "diff", "-Bub", @@ -111,13 +139,13 @@ public class HaskellHelper { /*else System.out.println(ANSI.blue(s));*/ } p.waitFor(); - } catch (Exception e) { - e.printStackTrace(); - } } new File(outPath+"+").renameTo(dest); if (dest.lastModified() <= f.lastModified()) dest.setLastModified(f.lastModified()+1); + } catch (Exception e) { + e.printStackTrace(); + } } }