|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2004, 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 8-16
Link Here
|
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Martin Oberhuber (Wind River) - [232426] createSymLink() method |
10 |
* Martin Oberhuber (Wind River) - [232426] createSymLink() method |
|
|
11 |
* Martin Oberhuber (Wind River) - [335864] ResourceAttributeTest fails on Win7 |
| 11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 12 |
package org.eclipse.core.tests.harness; |
13 |
package org.eclipse.core.tests.harness; |
| 13 |
|
14 |
|
|
|
15 |
import org.osgi.framework.Version; |
| 16 |
|
| 14 |
import java.io.ByteArrayInputStream; |
17 |
import java.io.ByteArrayInputStream; |
| 15 |
import java.io.File; |
18 |
import java.io.File; |
| 16 |
import java.io.FileInputStream; |
19 |
import java.io.FileInputStream; |
|
Lines 210-221
Link Here
|
| 210 |
String[] envp = {}; |
213 |
String[] envp = {}; |
| 211 |
try { |
214 |
try { |
| 212 |
Process p; |
215 |
Process p; |
| 213 |
if (isWindowsVista() || isWindows7()) { |
216 |
if (isWindowsVistaOrHigher()) { |
| 214 |
if (isDir) { |
217 |
if (isDir) { |
| 215 |
String[] cmd = {"mklink", "/d", linkName, linkTgt}; |
218 |
String[] cmd = {"cmd", "/c", "mklink", "/d", linkName, linkTgt}; |
| 216 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
219 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
| 217 |
} else { |
220 |
} else { |
| 218 |
String[] cmd = {"mklink", linkName, linkTgt}; |
221 |
String[] cmd = {"cmd", "/c", "mklink", linkName, linkTgt}; |
| 219 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
222 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
| 220 |
} |
223 |
} |
| 221 |
} else { |
224 |
} else { |
|
Lines 223-229
Link Here
|
| 223 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
226 |
p = Runtime.getRuntime().exec(cmd, envp, basedir); |
| 224 |
} |
227 |
} |
| 225 |
int exitcode = p.waitFor(); |
228 |
int exitcode = p.waitFor(); |
| 226 |
assertEquals(exitcode, 0); |
229 |
assertEquals("createSymLink: exitcode", 0, exitcode); |
| 227 |
} catch (IOException e) { |
230 |
} catch (IOException e) { |
| 228 |
fail("createSymLink", e); |
231 |
fail("createSymLink", e); |
| 229 |
} catch (InterruptedException e) { |
232 |
} catch (InterruptedException e) { |
|
Lines 314-332
Link Here
|
| 314 |
return System.currentTimeMillis() + "-" + Math.random(); |
317 |
return System.currentTimeMillis() + "-" + Math.random(); |
| 315 |
} |
318 |
} |
| 316 |
|
319 |
|
|
|
320 |
private static boolean isWindowsMinVersion(int major, int minor, int micro) { |
| 321 |
if (Platform.getOS().equals(Platform.OS_WIN32)) { |
| 322 |
try { |
| 323 |
Version v = Version.parseVersion(System.getProperty("org.osgi.framework.os.version")); //$NON-NLS-1$ |
| 324 |
return v.compareTo(new Version(major,minor,micro))>=0; |
| 325 |
} catch(IllegalArgumentException e) { |
| 326 |
/* drop down to returning false */ |
| 327 |
} |
| 328 |
|
| 329 |
} |
| 330 |
return false; |
| 331 |
} |
| 332 |
|
| 317 |
/** |
333 |
/** |
| 318 |
* Test if running on Windows Vista. |
334 |
* Test if running on Windows Vista or higher. |
| 319 |
* @return <code>true</code> if running on Windows Vista. |
335 |
* @return <code>true</code> if running on Windows Vista or higher. |
| 320 |
*/ |
336 |
*/ |
| 321 |
private static boolean isWindowsVista() { |
337 |
private static boolean isWindowsVistaOrHigher() { |
| 322 |
return Platform.getOS().equals(Platform.OS_WIN32) && "6.0".equals(System.getProperty("org.osgi.framework.os.version")); //$NON-NLS-1$ //$NON-NLS-2$ |
338 |
return isWindowsMinVersion(6,0,0); |
| 323 |
} |
339 |
} |
| 324 |
|
340 |
|
| 325 |
private static boolean isWindows7() { |
|
|
| 326 |
return "Windows7".equals(System.getProperty("org.osgi.framework.os.name")) //$NON-NLS-1$ //$NON-NLS-2$ |
| 327 |
|| (Platform.getOS().equals(Platform.OS_WIN32) && "6.1.0".equals(System.getProperty("org.osgi.framework.os.version"))); //$NON-NLS-1$ //$NON-NLS-2$ |
| 328 |
} |
| 329 |
|
| 330 |
/** |
341 |
/** |
| 331 |
* Copy the data from the input stream to the output stream. |
342 |
* Copy the data from the input stream to the output stream. |
| 332 |
* Close both streams when finished. |
343 |
* Close both streams when finished. |