提交 247027a8 编写于 作者: M malenkov

8035699: File choosers should be choosier

Reviewed-by: alexsch, art, skoivu
上级 f5768513
...@@ -718,7 +718,8 @@ class WindowsFileSystemView extends FileSystemView { ...@@ -718,7 +718,8 @@ class WindowsFileSystemView extends FileSystemView {
* @return the Desktop folder. * @return the Desktop folder.
*/ */
public File getHomeDirectory() { public File getHomeDirectory() {
return getRoots()[0]; File[] roots = getRoots();
return (roots.length == 0) ? null : roots[0];
} }
/** /**
......
...@@ -583,11 +583,18 @@ final class Win32ShellFolder2 extends ShellFolder { ...@@ -583,11 +583,18 @@ final class Win32ShellFolder2 extends ShellFolder {
// Needs to be accessible to Win32ShellFolderManager2 // Needs to be accessible to Win32ShellFolderManager2
static String getFileSystemPath(final int csidl) throws IOException, InterruptedException { static String getFileSystemPath(final int csidl) throws IOException, InterruptedException {
return invoke(new Callable<String>() { String path = invoke(new Callable<String>() {
public String call() throws IOException { public String call() throws IOException {
return getFileSystemPath0(csidl); return getFileSystemPath0(csidl);
} }
}, IOException.class); }, IOException.class);
if (path != null) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
}
}
return path;
} }
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
......
...@@ -142,6 +142,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -142,6 +142,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
if (desktop == null) { if (desktop == null) {
try { try {
desktop = new Win32ShellFolder2(DESKTOP); desktop = new Win32ShellFolder2(DESKTOP);
} catch (SecurityException e) {
// Ignore error
} catch (IOException e) { } catch (IOException e) {
// Ignore error // Ignore error
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -155,6 +157,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -155,6 +157,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
if (drives == null) { if (drives == null) {
try { try {
drives = new Win32ShellFolder2(DRIVES); drives = new Win32ShellFolder2(DRIVES);
} catch (SecurityException e) {
// Ignore error
} catch (IOException e) { } catch (IOException e) {
// Ignore error // Ignore error
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -171,6 +175,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -171,6 +175,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
if (path != null) { if (path != null) {
recent = createShellFolder(getDesktop(), new File(path)); recent = createShellFolder(getDesktop(), new File(path));
} }
} catch (SecurityException e) {
// Ignore error
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Ignore error // Ignore error
} catch (IOException e) { } catch (IOException e) {
...@@ -184,6 +190,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -184,6 +190,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
if (network == null) { if (network == null) {
try { try {
network = new Win32ShellFolder2(NETWORK); network = new Win32ShellFolder2(NETWORK);
} catch (SecurityException e) {
// Ignore error
} catch (IOException e) { } catch (IOException e) {
// Ignore error // Ignore error
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -207,6 +215,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -207,6 +215,8 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
personal.setIsPersonal(); personal.setIsPersonal();
} }
} }
} catch (SecurityException e) {
// Ignore error
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Ignore error // Ignore error
} catch (IOException e) { } catch (IOException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册