Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2013-02-19 18:22:07 -0500
committerJeff Johnston2013-02-20 16:16:50 -0500
commit18ff30de24e745ca9f221c49ff8bd219837022c7 (patch)
treea3c29211fc06a2e738b2be12f17057d2d14cd77e
parent1908efec3811e8c24030a5b38140b00fbb66ca61 (diff)
downloadorg.eclipse.cdt-18ff30de24e745ca9f221c49ff8bd219837022c7.tar.gz
org.eclipse.cdt-18ff30de24e745ca9f221c49ff8bd219837022c7.tar.xz
org.eclipse.cdt-18ff30de24e745ca9f221c49ff8bd219837022c7.zip
Bug 400972: Creating new C/C++ project in existing read-only
directory should be disallowed Change-Id: I75090498bd4f408d77ad17491f50f4fd66850c97 Reviewed-on: https://git.eclipse.org/r/10404 Reviewed-by: Jesse Weinstein <Jesse.Weinstein@clinicomp.com> Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java7
6 files changed, 15 insertions, 2 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
index 69436a7ed9..18939f441d 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
@@ -186,6 +186,7 @@ public class Messages extends NLS {
public static String NewMakeProjFromExistingPage_7;
public static String NewMakeProjFromExistingPage_8;
public static String NewMakeProjFromExistingPage_9;
+ public static String NewMakeProjFromExistingPage_DirReadOnlyError;
public static String NewVarDialog_0;
public static String NewVarDialog_1;
public static String PreferredToolchainsTab_0;
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
index ac4acf5dce..d45a0a1285 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
@@ -152,6 +152,8 @@ NewMakeProjFromExistingPage_6=Browse...
NewMakeProjFromExistingPage_7=Select root directory of existing code
NewMakeProjFromExistingPage_8=Not a valid directory
NewMakeProjFromExistingPage_9=Languages
+NewMakeProjFromExistingPage_DirReadOnlyError=Directory is read-only
+
# ----------- Configuration Selection Page -----------
BuildPropertyPage_error_Unknown_tree_element=Unknown type of element in tree of type {0}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
index 8848e47386..b9f817f07b 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
@@ -155,10 +155,13 @@ public class NewMakeProjFromExistingPage extends WizardPage {
else {
final File file= new File(loc);
if (file.isDirectory()) {
+ // Ensure we can create files in the directory.
+ if (!file.canWrite())
+ msg = Messages.NewMakeProjFromExistingPage_DirReadOnlyError;
// Set the project name to the directory name but not if the user has supplied a name
// (bugzilla 368987). Use a job to ensure proper sequence of activity, as setting the Text
// will invoke the listener, which will invoke this method.
- if (!projectNameSetByUser && !name.equals(file.getName())) {
+ else if (!projectNameSetByUser && !name.equals(file.getName())) {
WorkbenchJob wjob = new WorkbenchJob("update project name") { //$NON-NLS-1$
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java
index 29c4a9f4a3..8748aa13af 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java
@@ -105,6 +105,7 @@ public class Messages extends NLS {
public static String CMainWizardPage_5;
public static String CMainWizardPage_6;
public static String CMainWizardPage_7;
+ public static String CMainWizardPage_DirReadOnlyError;
public static String ConfigDescriptionTab_0;
public static String ConfigDescriptionTab_1;
public static String ConfigDescriptionTab_2;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties
index fb82cc455f..839d769eab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties
@@ -273,6 +273,7 @@ CMainWizardPage_3=No project types available. Project cannot be created
CMainWizardPage_5=Cannot create ICProjectTypeHandler:
CMainWizardPage_6=File with specified name already exists.
CMainWizardPage_7=Directory with specified name already exists.
+CMainWizardPage_DirReadOnlyError=Directory with specified name already exists and is read-only.
ProjectContentsArea_0=Browse...
ProjectContentsArea_1=Use default location
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
index d8b09411ef..133785d177 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
@@ -211,7 +211,12 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
IFileInfo f = fs.fetchInfo();
if (f.exists()) {
if (f.isDirectory()) {
- setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING);
+ if (f.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) {
+ setErrorMessage(Messages.CMainWizardPage_DirReadOnlyError);
+ return false;
+ }
+ else
+ setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING);
} else {
setErrorMessage(Messages.CMainWizardPage_6);
return false;

Back to the top