From e5f01aa4ad33be323c1657d156353722ea0dda9f Mon Sep 17 00:00:00 2001 From: jihoon song Date: Mon, 5 Sep 2011 18:49:16 +0900 Subject: [PATCH] [Title] added file utility [Type] Enhancement [Module] common-plugins [Priority] Minor [CQ#] -- [Redmine#] -- [Problem] [Cause] [Solution] [TestCase] Change-Id: I2433ca409d9ed06976c6a730b5b0f8230e95dd04 --- .../src/com/samsung/slp/common/util/FileUtil.java | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java b/com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java index 51314e6..1a83a17 100644 --- a/com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java +++ b/com.samsung.slp.common/src/com/samsung/slp/common/util/FileUtil.java @@ -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 } (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 } (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 } (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 } (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 null if progress reporting and cancellation are not desired + * + * @author Jihoon Song {@literal } (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); + } } -- 2.7.4