package com.dw.lib.cli;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

import com.dw.lib.FileUtils;

public class CppCpCLI {

	public static void help() {
		System.out.println("cppcp  <input folder> <output folder>");
		System.out.println("output folder: ./cpp/");
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		if(args.length != 2) {
			help();
			return;
		}
		
		FileUtils fileUtils = new FileUtils();
		String mainPath = args[0];
		String outputFolder = args[1];
		
		if (!mainPath.endsWith("/")) {
			mainPath += "/";
		}
		
		if (!outputFolder.endsWith("/")) {
			outputFolder += "/";
		}

		try {
			List<Path> headerFile = fileUtils.listFiles(mainPath, ".*.h");
			for(Path p : headerFile) {
				String outputFile = p.toString().replace(mainPath, outputFolder);
				File output = new File(outputFile);
				if(!fileUtils.isExisted(output.getParent())) {
					(new File(output.getParent())).mkdirs();
				}
				fileUtils.copyFileUsingStream(p.toFile(), output);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

@@ -118,16 +118,53 @@
 .List;%0A%0A
+import com.dw.lib.EnvironmentHelper;%0A
 import c
@@ -302,16 +302,50 @@
 der%3E%22);%0A
+%09%09System.out.println(%22use path%22);%0A
 %09%09System
@@ -626,17 +626,194 @@
 s%5B1%5D;%0A%09%09
-%0A
+boolean isWindows = EnvironmentHelper.getOSType() == EnvironmentHelper.OSType.WIN;%0A%09%09%0A%09%09if(isWindows) %7B%0A%09%09%09if (!mainPath.endsWith(%22%5C%5C%22)) %7B%0A%09%09%09%09mainPath += %22%5C%5C%22;%0A%09%09%09%7D%0A%09%09%7D else %7B%0A%09
 %09%09if (!m
@@ -840,16 +840,17 @@
 )) %7B%0A%09%09%09
+%09
 mainPath
@@ -858,23 +858,128 @@
 += %22/%22;%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09%0A
+%09%09if(isWindows) %7B%0A%09%09%09if (!outputFolder.endsWith(%22%5C%5C%22)) %7B%0A%09%09%09%09outputFolder += %22%5C%5C%22;%0A%09%09%09%7D%0A%09%09%7D else %7B%0A%09
 %09%09if (!o
@@ -1007,16 +1007,17 @@
 %22/%22)) %7B%0A
+%09
 %09%09%09outpu
@@ -1032,16 +1032,21 @@
 += %22/%22;%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%0A%09%09t

update cppcp for windows