Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java')
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java51
1 files changed, 47 insertions, 4 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java
index f4a6512630..40f922da45 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoProject.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.linuxtools.rpm.createrepo;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
@@ -19,7 +22,12 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Messages;
+import org.osgi.framework.FrameworkUtil;
/**
* This class will contain the current project and basic operations of the
@@ -66,10 +74,7 @@ public class CreaterepoProject {
* @throws CoreException Thrown when unable to create the folders.
*/
private void intitialize() throws CoreException {
- content = getProject().getFolder(ICreaterepoConstants.CONTENT_FOLDER);
- if (!content.exists()) {
- content.create(false, true, monitor);
- }
+ createContentFolder();
if (repoFile == null) {
for (IResource child : getProject().members()) {
String extension = child.getFileExtension();
@@ -83,6 +88,44 @@ public class CreaterepoProject {
}
/**
+ * Create the content folder if it doesn't exist.
+ *
+ * @throws CoreException
+ */
+ private void createContentFolder() throws CoreException {
+ content = getProject().getFolder(ICreaterepoConstants.CONTENT_FOLDER);
+ if (!content.exists()) {
+ content.create(false, true, monitor);
+ }
+ }
+
+ /**
+ * Import an RPM file outside of the eclipse workspace.
+ *
+ * @param externalFile The external file to import.
+ * @throws CoreException Thrown when failure to create a workspace file.
+ */
+ public void importRPM(File externalFile) throws CoreException {
+ // must put imported RPMs into the content folder; create if missing
+ if (content == null) {
+ createContentFolder();
+ }
+ IFile file = getContentFolder().getFile(new Path(externalFile.getName()));
+ if (!file.exists()) {
+ try {
+ file.create(new FileInputStream(externalFile), false, monitor);
+ } catch (FileNotFoundException e) {
+ IStatus status = new Status(
+ IStatus.ERROR,
+ FrameworkUtil.getBundle(CreaterepoProject.class).getSymbolicName(),
+ Messages.CreaterepoProject_errorGettingFile, null);
+ throw new CoreException(status);
+ }
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ }
+
+ /**
* Get the project.
*
* @return The project.

Back to the top