View | Details | Raw Unified | Return to bug 168445 | Differences between
and this patch

Collapse All | Expand All

(-)eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/LocationManager.java (-3 / +22 lines)
Lines 232-238 Link Here
232
232
233
		File fileTest = null;
233
		File fileTest = null;
234
		try {
234
		try {
235
			fileTest = File.createTempFile("writtableArea", null, installDir); //$NON-NLS-1$
235
			// we use the .dll suffix to properly test on Vista virtual directories
236
        	// on Vista you are not allowed to write executable files on virtual directories like "Program Files"
237
            fileTest = File.createTempFile("writtableArea", ".dll", installDir); //$NON-NLS-1$ //$NON-NLS-2$
236
		} catch (IOException e) {
238
		} catch (IOException e) {
237
			//If an exception occured while trying to create the file, it means that it is not writtable
239
			//If an exception occured while trying to create the file, it means that it is not writtable
238
			return false;
240
			return false;
Lines 253-258 Link Here
253
		if (installURL == null)
255
		if (installURL == null)
254
			return null;
256
			return null;
255
		File installDir = new File(installURL.getFile());
257
		File installDir = new File(installURL.getFile());
258
		// compute an install dir hash to prevent configuration area collisions with other eclipse installs
259
        int hashCode;
260
        try {
261
        	hashCode = installDir.getCanonicalPath().hashCode();
262
        } catch (IOException ioe) {
263
        	// fall back to absolute path
264
        	hashCode = installDir.getAbsolutePath().hashCode();
265
        }
266
       	if (hashCode < 0)
267
       		hashCode = -(hashCode);
268
       	String installDirHash = String.valueOf(hashCode);
269
256
		String appName = "." + ECLIPSE; //$NON-NLS-1$
270
		String appName = "." + ECLIPSE; //$NON-NLS-1$
257
		File eclipseProduct = new File(installDir, PRODUCT_SITE_MARKER);
271
		File eclipseProduct = new File(installDir, PRODUCT_SITE_MARKER);
258
		if (eclipseProduct.exists()) {
272
		if (eclipseProduct.exists()) {
Lines 265-276 Link Here
265
				String appVersion = props.getProperty(PRODUCT_SITE_VERSION);
279
				String appVersion = props.getProperty(PRODUCT_SITE_VERSION);
266
				if (appVersion == null || appVersion.trim().length() == 0)
280
				if (appVersion == null || appVersion.trim().length() == 0)
267
					appVersion = ""; //$NON-NLS-1$
281
					appVersion = ""; //$NON-NLS-1$
268
				appName += File.separator + appId + "_" + appVersion; //$NON-NLS-1$
282
				appName += File.separator + appId + "_" + appVersion + "_" + installDirHash; //$NON-NLS-1$ //$NON-NLS-2$
269
			} catch (IOException e) {
283
			} catch (IOException e) {
270
				// Do nothing if we get an exception.  We will default to a standard location 
284
				// Do nothing if we get an exception.  We will default to a standard location 
271
				// in the user's home dir.
285
				// in the user's home dir.
286
            	// add the hash to help prevent collisions
287
            	appName += File.separator + installDirHash;
272
			}
288
			}
273
		}
289
		} else {
290
        	// add the hash to help prevent collisions
291
        	appName += File.separator + installDirHash;
292
        }
274
		String userHome = FrameworkProperties.getProperty(PROP_USER_HOME);
293
		String userHome = FrameworkProperties.getProperty(PROP_USER_HOME);
275
		return new File(userHome, appName + "/" + pathAppendage).getAbsolutePath(); //$NON-NLS-1$
294
		return new File(userHome, appName + "/" + pathAppendage).getAbsolutePath(); //$NON-NLS-1$
276
	}
295
	}
(-)src/org/eclipse/equinox/launcher/Main.java (-39 / +58 lines)
Lines 911-941 Link Here
911
911
912
    private static URL buildURL(String spec, boolean trailingSlash) {
912
    private static URL buildURL(String spec, boolean trailingSlash) {
913
        if (spec == null)
913
        if (spec == null)
914
			return null;
914
            return null;
915
		boolean isFile = spec.startsWith(FILE_SCHEME);
915
        boolean isFile = spec.startsWith(FILE_SCHEME);
916
		try {
916
        try {
917
			if (isFile) {
917
            if (isFile) {
918
				File toAdjust = new File(spec.substring(5));
918
                File toAdjust = new File(spec.substring(5));
919
				if (toAdjust.isDirectory())
919
                if (toAdjust.isDirectory())
920
					return adjustTrailingSlash(toAdjust.toURL(), trailingSlash);
920
                    return adjustTrailingSlash(toAdjust.toURL(), trailingSlash);
921
				return toAdjust.toURL();
921
                    return toAdjust.toURL();
922
			}
923
			return new URL(spec);
924
		} catch (MalformedURLException e) {
925
			// if we failed and it is a file spec, there is nothing more we can do
926
			// otherwise, try to make the spec into a file URL.
927
			if (isFile)
928
				return null;
929
			try {
930
				File toAdjust = new File(spec);
931
				if (toAdjust.isDirectory())
932
					return adjustTrailingSlash(toAdjust.toURL(), trailingSlash);
933
				return toAdjust.toURL();
934
			} catch (MalformedURLException e1) {
935
				return null;
936
			}
922
			}
937
		}
923
                return new URL(spec);
938
	}
924
        } catch (MalformedURLException e) {
925
            // if we failed and it is a file spec, there is nothing more we can do
926
            // otherwise, try to make the spec into a file URL.
927
            if (isFile)
928
                return null;
929
            try {
930
                File toAdjust = new File(spec);
931
                if (toAdjust.isDirectory())
932
                    return adjustTrailingSlash(toAdjust.toURL(), trailingSlash);
933
                    return toAdjust.toURL();
934
            } catch (MalformedURLException e1) {
935
                return null;
936
            }
937
        }
938
    }
939
939
940
    private static URL adjustTrailingSlash(URL url, boolean trailingSlash) throws MalformedURLException {
940
    private static URL adjustTrailingSlash(URL url, boolean trailingSlash) throws MalformedURLException {
941
        String file = url.getFile();
941
        String file = url.getFile();
Lines 1015-1021 Link Here
1015
1015
1016
        File fileTest = null;
1016
        File fileTest = null;
1017
        try {
1017
        try {
1018
            fileTest = File.createTempFile("writtableArea", null, installDir); //$NON-NLS-1$
1018
        	// we use the .dll suffix to properly test on Vista virtual directories
1019
        	// on Vista you are not allowed to write executable files on virtual directories like "Program Files"
1020
            fileTest = File.createTempFile("writtableArea", ".dll", installDir); //$NON-NLS-1$ //$NON-NLS-2$
1019
        } catch (IOException e) {
1021
        } catch (IOException e) {
1020
            //If an exception occured while trying to create the file, it means that it is not writtable
1022
            //If an exception occured while trying to create the file, it means that it is not writtable
1021
            return false;
1023
            return false;
Lines 1042-1047 Link Here
1042
        if (installURL == null)
1044
        if (installURL == null)
1043
            return null;
1045
            return null;
1044
        File installDir = new File(installURL.getFile());
1046
        File installDir = new File(installURL.getFile());
1047
        // compute an install dir hash to prevent configuration area collisions with other eclipse installs
1048
        int hashCode;
1049
        try {
1050
        	hashCode = installDir.getCanonicalPath().hashCode();
1051
        } catch (IOException ioe) {
1052
        	// fall back to absolute path
1053
        	hashCode = installDir.getAbsolutePath().hashCode();
1054
        }
1055
       	if (hashCode < 0)
1056
       		hashCode = -(hashCode);
1057
       	String installDirHash = String.valueOf(hashCode);
1058
1045
        String appName = "." + ECLIPSE; //$NON-NLS-1$
1059
        String appName = "." + ECLIPSE; //$NON-NLS-1$
1046
        File eclipseProduct = new File(installDir, PRODUCT_SITE_MARKER);
1060
        File eclipseProduct = new File(installDir, PRODUCT_SITE_MARKER);
1047
        if (eclipseProduct.exists()) {
1061
        if (eclipseProduct.exists()) {
Lines 1054-1064 Link Here
1054
                String appVersion = props.getProperty(PRODUCT_SITE_VERSION);
1068
                String appVersion = props.getProperty(PRODUCT_SITE_VERSION);
1055
                if (appVersion == null || appVersion.trim().length() == 0)
1069
                if (appVersion == null || appVersion.trim().length() == 0)
1056
                    appVersion = ""; //$NON-NLS-1$
1070
                    appVersion = ""; //$NON-NLS-1$
1057
                appName += File.separator + appId + "_" + appVersion; //$NON-NLS-1$
1071
                appName += File.separator + appId + "_" + appVersion + "_" + installDirHash; //$NON-NLS-1$ //$NON-NLS-2$
1058
            } catch (IOException e) {
1072
            } catch (IOException e) {
1059
                // Do nothing if we get an exception.  We will default to a standard location 
1073
                // Do nothing if we get an exception.  We will default to a standard location 
1060
                // in the user's home dir.
1074
                // in the user's home dir.
1075
            	// add the hash to help prevent collisions
1076
            	appName += File.separator + installDirHash;
1061
            }
1077
            }
1078
        } else {
1079
        	// add the hash to help prevent collisions
1080
        	appName += File.separator + installDirHash;
1062
        }
1081
        }
1063
        String userHome = System.getProperty(PROP_USER_HOME);
1082
        String userHome = System.getProperty(PROP_USER_HOME);
1064
        return new File(userHome, appName + "/" + pathAppendage).getAbsolutePath(); //$NON-NLS-1$
1083
        return new File(userHome, appName + "/" + pathAppendage).getAbsolutePath(); //$NON-NLS-1$
Lines 1145-1151 Link Here
1145
            result = 13;
1164
            result = 13;
1146
        } finally {
1165
        } finally {
1147
            // always try putting down the splash screen just in case the application failed to do so
1166
            // always try putting down the splash screen just in case the application failed to do so
1148
            takeDownSplash();   
1167
            takeDownSplash();           
1149
            if(bridge != null)
1168
            if(bridge != null)
1150
            	bridge.uninitialize();
1169
            	bridge.uninitialize();
1151
        }
1170
        }
Lines 1734-1750 Link Here
1734
     * Take down the splash screen. 
1753
     * Take down the splash screen. 
1735
     */
1754
     */
1736
    protected void takeDownSplash() {
1755
    protected void takeDownSplash() {
1737
		if (splashDown || bridge == null) // splash is already down
1756
        if (splashDown || bridge == null) // splash is already down
1738
			return;
1757
            return;
1739
1758
1740
		splashDown = bridge.takeDownSplash();
1759
		splashDown = bridge.takeDownSplash();
1741
1760
        
1742
		try {
1761
        try {
1743
			Runtime.getRuntime().removeShutdownHook(splashHandler);
1762
        	Runtime.getRuntime().removeShutdownHook(splashHandler);
1744
		} catch (Throwable e) {
1763
        } catch (Throwable e) {
1745
			// OK to ignore this, happens when the VM is already shutting down
1764
        	// OK to ignore this, happens when the VM is already shutting down
1746
		}
1765
        }
1747
	}
1766
    }
1748
1767
1749
    /*
1768
    /*
1750
     * Return path of the splash image to use.  First search the defined splash path.
1769
     * Return path of the splash image to use.  First search the defined splash path.
Lines 1985-1993 Link Here
1985
        }
2004
        }
1986
        if (urlString.startsWith(PLATFORM_URL)) {
2005
        if (urlString.startsWith(PLATFORM_URL)) {
1987
            String path = urlString.substring(PLATFORM_URL.length());
2006
            String path = urlString.substring(PLATFORM_URL.length());
1988
			return getInstallLocation() + path;
2007
            return getInstallLocation() + path;
1989
		}
2008
		}
1990
		return urlString;
2009
            return urlString;
1991
    }
2010
    }
1992
2011
1993
    /*
2012
    /*
Lines 2285-2291 Link Here
2285
                                cur = 1;
2304
                                cur = 1;
2286
                                return allPermission;
2305
                                return allPermission;
2287
                            }
2306
                            }
2288
                            throw new NoSuchElementException();
2307
                                throw new NoSuchElementException();
2289
                        }
2308
                        }
2290
                    };
2309
                    };
2291
                }
2310
                }

Return to bug 168445