[Title] added file utility
authorjihoon song <jihoon80.song@samsung.com>
Mon, 5 Sep 2011 09:49:16 +0000 (18:49 +0900)
committerjihoon song <jihoon80.song@samsung.com>
Mon, 5 Sep 2011 09:53:36 +0000 (18:53 +0900)
[Type] Enhancement
[Module] common-plugins
[Priority] Minor
[CQ#] --
[Redmine#] --
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I2433ca409d9ed06976c6a730b5b0f8230e95dd04

com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java

index 51314e6..1a83a17 100644 (file)
@@ -23,6 +23,13 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileSystem;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
 
 /**
  * @author Changhyun Lee {@literal <changhyun1.lee@samsung.com>} (S-Core)
@@ -60,7 +67,7 @@ public class FileUtil {
     /** 
      * return file extension from given full file name
      * 
-     * @author jihoon80.song@samsung.com, S-Core Inc.
+     * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
      */
     public static String getFileExtension(String fullName) {
         if (fullName == null) {
@@ -75,7 +82,7 @@ public class FileUtil {
     /** 
      * return file name without file extension from given full file name
      * 
-     * @author jihoon80.song@samsung.com, S-Core Inc.
+     * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
      */
     public static String getFileNameWithoutExtension(String fullName) {
         if (fullName == null) {
@@ -90,7 +97,7 @@ public class FileUtil {
     /**
      * delete file and its children.
      * 
-     * @author jihoon80.song@samsung.com, S-Core Inc.
+     * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
      */
     public static boolean recursiveDelete(File file) {
         boolean result = true;
@@ -113,4 +120,18 @@ public class FileUtil {
         return result;
     }
 
+    /**
+     * copy file or directory using Eclipse File System
+     * 
+     * @param source The source URI of the copy.
+     * @param destination The destination URI of the copy.
+     * @param options bit-wise or of option flag constants ({@link EFS#OVERWRITE} or {@link EFS#SHALLOW}).
+     * @param monitor a progress monitor, or <code>null</code> if progress reporting and cancellation are not desired
+     * 
+     * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
+     */
+    public static void copyUsingEFS(URI source, URI destination, int options, IProgressMonitor monitor) throws CoreException {
+        IFileSystem fileSystem = EFS.getLocalFileSystem();
+        fileSystem.getStore(source).copy(fileSystem.getStore(destination), options, monitor);
+    }
 }