add \Box
[wix.git] / src / HaskellHelper.java
index 753c5b8..4e3b2c6 100644 (file)
@@ -79,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));
@@ -90,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);
@@ -97,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",
@@ -113,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();
+                }
         }
     }