Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2019-12-24 08:54:40 +0000
committerEd Merks2019-12-24 08:54:40 +0000
commit8144483681c0d27350923526454fb5f6c81419b2 (patch)
tree6fa2baa46738fc92ffb8dce265fb8a143bae60c5
parentc3a3766bc80e37a90b741d4b6a734f330213ecad (diff)
downloadrt.equinox.p2-I20191226-1800.tar.gz
rt.equinox.p2-I20191226-1800.tar.xz
rt.equinox.p2-I20191226-1800.zip
side-effect of changing File.lastModified Change-Id: I8b6389654dbbb03cfa08252c520f12b225a708c8 Signed-off-by: Ed Merks <ed.merks@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java21
4 files changed, 7 insertions, 29 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
index 58bb0966b..22b65a2e1 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java
@@ -17,6 +17,7 @@ package org.eclipse.equinox.internal.p2.artifact.repository;
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.URIUtil;
@@ -94,15 +95,9 @@ public class Activator implements BundleActivator {
private boolean isReadOnly(File file) {
if (file == null)
return true; // If we've reached the root, then return true
+
if (file.exists()) {
- try {
- // on Vista/Windows 7 you are not allowed to write executable files on virtual directories like "Program Files"
- File tmpTestFile = File.createTempFile(".artifactlocktest", ".dll", file); //$NON-NLS-1$ //$NON-NLS-2$
- tmpTestFile.delete();
- return false;
- } catch (IOException e) {
- return true; // permission issue to create new file, so it's readonly
- }
+ return !Files.isWritable(file.toPath());
}
return isReadOnly(file.getParentFile());
diff --git a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
index bf6eea411..fb904f8a0 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.director.app;singleton:=true
-Bundle-Version: 1.1.400.qualifier
+Bundle-Version: 1.1.500.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.director.app.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.p2.director.app/pom.xml b/bundles/org.eclipse.equinox.p2.director.app/pom.xml
index 0400ff851..288cd287b 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.director.app/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.director.app</artifactId>
- <version>1.1.400-SNAPSHOT</version>
+ <version>1.1.500-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index 570a19e75..3705a864a 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -26,6 +26,7 @@ import static org.eclipse.equinox.internal.p2.director.app.Activator.ID;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.file.Files;
import java.security.cert.Certificate;
import java.util.*;
import java.util.Map.Entry;
@@ -1360,24 +1361,6 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private static boolean canWrite(File installDir) {
installDir.mkdirs(); //Force create the folders because otherwise the call to canWrite fails on Mac
- if (installDir.canWrite() == false)
- return false;
-
- if (!installDir.isDirectory())
- return false;
-
- File fileTest = null;
- try {
- // we use the .dll suffix to properly test on Vista virtual directories
- // on Vista you are not allowed to write executable files on virtual directories like "Program Files"
- fileTest = File.createTempFile("writableArea", ".dll", installDir); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (IOException e) {
- //If an exception occured while trying to create the file, it means that it is not writable
- return false;
- } finally {
- if (fileTest != null)
- fileTest.delete();
- }
- return true;
+ return installDir.isDirectory() && Files.isWritable(installDir.toPath());
}
}

Back to the top