Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2008-04-09 20:27:26 +0000
committerAndrew Niefer2008-04-09 20:27:26 +0000
commit10ed64307df5a27e1fd13418a64d54dda239b626 (patch)
tree2f119a48d446327f47efe37c5a037af9f3889741 /bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
parent82d628e7b87d48a7b658e883fc1bbbd6349c1fc8 (diff)
downloadrt.equinox.p2-10ed64307df5a27e1fd13418a64d54dda239b626.tar.gz
rt.equinox.p2-10ed64307df5a27e1fd13418a64d54dda239b626.tar.xz
rt.equinox.p2-10ed64307df5a27e1fd13418a64d54dda239b626.zip
bug 221710, bug 222621, chmod & ln on plugins and rootfiles
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
new file mode 100644
index 000000000..8b868555a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
+import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.osgi.util.NLS;
+
+public class ChmodAction extends ProvisioningAction {
+ public static final String ID = "chmod"; //$NON-NLS-1$
+
+ public IStatus execute(Map parameters) {
+ String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR);
+ if (targetDir == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ID));
+ if (targetDir.equals(ActionConstants.PARM_ARTIFACT)) {
+ try {
+ targetDir = Util.resolveArtifactParam(parameters);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ File dir = new File(targetDir);
+ if (!dir.isDirectory()) {
+ return Util.createError(NLS.bind(Messages.artifact_not_directory, dir));
+ }
+ }
+ String targetFile = (String) parameters.get(ActionConstants.PARM_TARGET_FILE);
+ if (targetFile == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_FILE, ID));
+
+ String permissions = (String) parameters.get(ActionConstants.PARM_PERMISSIONS);
+ if (permissions == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PERMISSIONS, ID));
+
+ chmod(targetDir, targetFile, permissions);
+ return Status.OK_STATUS;
+ }
+
+ public IStatus undo(Map parameters) {
+ //TODO: implement undo ??
+ return Status.OK_STATUS;
+ }
+
+ private void chmod(String targetDir, String targetFile, String perms) {
+ Runtime r = Runtime.getRuntime();
+ try {
+ r.exec(new String[] {"chmod", perms, targetDir + IPath.SEPARATOR + targetFile}); //$NON-NLS-1$
+ } catch (IOException e) {
+ // FIXME: we should probably throw some sort of error here
+ }
+ }
+}

Back to the top