diff options
author | Thomas Watson | 2013-04-16 01:49:44 +0000 |
---|---|---|
committer | Thomas Watson | 2013-04-16 01:49:44 +0000 |
commit | bda586273cfe19c14ef7cc12517c6f6c5b7d68d0 (patch) | |
tree | ef8c646cb859ee4452b56f123e5423cb668ce337 /bundles/org.eclipse.osgi/supplement | |
parent | 9e41c7919e2ab03e55431cb034179ec4d0fc570c (diff) | |
parent | 671f70606091d87ad97c36ae13febe49cf69cf11 (diff) | |
download | rt.equinox.framework-bda586273cfe19c14ef7cc12517c6f6c5b7d68d0.tar.gz rt.equinox.framework-bda586273cfe19c14ef7cc12517c6f6c5b7d68d0.tar.xz rt.equinox.framework-bda586273cfe19c14ef7cc12517c6f6c5b7d68d0.zip |
Merge branch 'master' into twatson/container
Conflicts:
bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/DirBundleFile.java
bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java
bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseLazyStarter.java
Diffstat (limited to 'bundles/org.eclipse.osgi/supplement')
-rw-r--r-- | bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java index 562738f73..7138c36a5 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2013 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 @@ -164,6 +164,44 @@ public class SecureAction { } /** + * Returns the absolute file. Same as calling + * file.getAbsoluteFile(). + * @param file a file object + * @return the absolute file. + */ + public File getAbsoluteFile(final File file) { + if (System.getSecurityManager() == null) + return file.getAbsoluteFile(); + return AccessController.doPrivileged(new PrivilegedAction<File>() { + public File run() { + return file.getAbsoluteFile(); + } + }, controlContext); + } + + /** + * Returns the canonical file. Same as calling + * file.getCanonicalFile(). + * @param file a file object + * @return the canonical file. + */ + public File getCanonicalFile(final File file) throws IOException { + if (System.getSecurityManager() == null) + return file.getCanonicalFile(); + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() { + public File run() throws IOException { + return file.getCanonicalFile(); + } + }, controlContext); + } catch (PrivilegedActionException e) { + if (e.getException() instanceof IOException) + throw (IOException) e.getException(); + throw (RuntimeException) e.getException(); + } + } + + /** * Returns true if a file exists, otherwise false is returned. Same as calling * file.exists(). * @param file a file object |