wlu: initial implementaiton
diff --git a/org.eclipse.epf.toolbox/src/org/eclipse/epf/toolbox/utils/CopyPIIFiles.java b/org.eclipse.epf.toolbox/src/org/eclipse/epf/toolbox/utils/CopyPIIFiles.java
new file mode 100644
index 0000000..143d100
--- /dev/null
+++ b/org.eclipse.epf.toolbox/src/org/eclipse/epf/toolbox/utils/CopyPIIFiles.java
@@ -0,0 +1,105 @@
+package org.eclipse.epf.toolbox.utils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class CopyPIIFiles {
+
+ private static CopyPIIFiles instance = new CopyPIIFiles();
+
+ private static boolean localDebug = true;
+
+ private static final String[] startWithFiles = {
+ "spalsh.",
+ };
+
+ private static final String[] types = {
+ ".properties",
+ ".htm",
+ ".html",
+ ".js",
+ };
+
+ private static Set<String> typeSet;
+
+ static {
+ typeSet = new HashSet<String>();
+ for (String type : types) {
+ typeSet.add(type);
+ }
+ }
+
+ //Hard coded parameters
+ private String sourceRootFolderStr = "c:\\tmp\\source";
+ private String targetRootFolderStr = "c:\\tmp\\target";
+
+ private File sourceRootFolder;
+ private File targetRootFolder;
+
+ public CopyPIIFiles() {
+ sourceRootFolder = new File(sourceRootFolderStr);
+ targetRootFolder = new File(targetRootFolderStr);
+ }
+
+ public static void main(String[] args) {
+ instance.execute();
+ }
+
+ public void execute() {
+ copy(sourceRootFolder, targetRootFolder);
+ }
+
+ private boolean copy(File srcFolder, File tgtFolder) {
+ boolean ret = copy_(srcFolder, tgtFolder);
+ if (localDebug) {
+ System.out.println("LD> copy_: " + ret + ", " + srcFolder); //$NON-NLS-1$
+ }
+ return ret;
+ }
+
+ private boolean copy_(File srcFolder, File tgtFolder) {
+ boolean anyFileCopied = false;
+
+ File[] files = srcFolder.listFiles();
+ if (files == null) {
+ return anyFileCopied;
+ }
+
+ List<File> subDirs = new ArrayList<File>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ subDirs.add(file);
+ } else {
+ String fileName = file.getName();
+ }
+ }
+
+ for (File subDir : subDirs) {
+ File tgtSubDir = new File(srcFolder, subDir.getName());
+ tgtSubDir.mkdir();
+ if (! copy(subDir, tgtSubDir)) {
+ tgtSubDir.delete();
+ }
+ }
+ return anyFileCopied;
+ }
+
+ private boolean toCopyFile(File file) {
+ String fileName = file.getName();
+ for (String str : startWithFiles) {
+ if (fileName.startsWith(str)) {
+ return true;
+ }
+ }
+ int ix = fileName.lastIndexOf(".");
+ if (ix < 0) {
+ return false;
+ }
+ String ext = fileName.substring(ix);
+ return typeSet.contains(ext);
+ }
+
+}