wlu: updated
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
index 143d100..240a13b 100644
--- 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
@@ -6,6 +6,8 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.epf.common.utils.FileUtil;
+
public class CopyPIIFiles {
private static CopyPIIFiles instance = new CopyPIIFiles();
@@ -33,8 +35,8 @@
}
//Hard coded parameters
- private String sourceRootFolderStr = "c:\\tmp\\source";
- private String targetRootFolderStr = "c:\\tmp\\target";
+ private String sourceRootFolderStr = "C:\\Documents and Settings\\wlu\\Desktop\\Dev\\aa_devTemp\\Rmc75SnapshortOn_04022009\\Rmc75SnapshortOn_04022009";
+ private String targetRootFolderStr = "C:\\Documents and Settings\\wlu\\Desktop\\Dev\\aa_devTemp\\Rmc75SnapshortOn_04022009\\RmcPIIFiles";
private File sourceRootFolder;
private File targetRootFolder;
@@ -49,42 +51,45 @@
}
public void execute() {
+ if (targetRootFolder.exists()) {
+ FileUtil.deleteAllFiles(targetRootFolder.getAbsolutePath());
+ } else {
+ targetRootFolder.mkdir();
+ }
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>();
+ int ccCount = 0;
for (File file : files) {
if (file.isDirectory()) {
subDirs.add(file);
} else {
- String fileName = file.getName();
+ if (toCopyFile(file)) {
+ ccCount++;
+ File tgtFile = new File(tgtFolder, file.getName());
+ FileUtil.copyFile(file, tgtFile);
+ }
}
}
+ if (localDebug && ccCount > 0) {
+ System.out.println("LD> # of file copied: " + ccCount + ", " + srcFolder.getAbsolutePath().substring(
+ sourceRootFolderStr.length()));
+ }
+
for (File subDir : subDirs) {
- File tgtSubDir = new File(srcFolder, subDir.getName());
+ File tgtSubDir = new File(tgtFolder, subDir.getName());
tgtSubDir.mkdir();
if (! copy(subDir, tgtSubDir)) {
tgtSubDir.delete();
}
}
- return anyFileCopied;
+ return ccCount > 0;
}
private boolean toCopyFile(File file) {