fixed show mapped drives in windows
This commit is contained in:
parent
a06d421e84
commit
dc6670ab96
@ -25,11 +25,36 @@ public class DriveSelector extends JDialog {
|
||||
((JComponent) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
// Get list of available drives
|
||||
File[] roots = File.listRoots();
|
||||
List<DriveInfo> drives = new ArrayList<>();
|
||||
java.util.Set<File> driveSet = new java.util.LinkedHashSet<>();
|
||||
|
||||
for (File root : roots) {
|
||||
drives.add(new DriveInfo(root));
|
||||
File[] roots = File.listRoots();
|
||||
if (roots != null) {
|
||||
for (File r : roots) {
|
||||
driveSet.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
// On Windows, additionally add mapped network drives if missed by listRoots
|
||||
if (cz.kamma.kfmanager.MainApp.CURRENT_OS == cz.kamma.kfmanager.MainApp.OS.WINDOWS) {
|
||||
javax.swing.filechooser.FileSystemView fsv = javax.swing.filechooser.FileSystemView.getFileSystemView();
|
||||
File[] fsvRoots = fsv.getRoots();
|
||||
if (fsvRoots != null) {
|
||||
for (File r : fsvRoots) {
|
||||
File[] devices = fsv.getFiles(r, false);
|
||||
if (devices != null) {
|
||||
for (File d : devices) {
|
||||
if (fsv.isDrive(d) || fsv.isFileSystemRoot(d)) {
|
||||
driveSet.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DriveInfo> drives = new ArrayList<>();
|
||||
for (File drive : driveSet) {
|
||||
drives.add(new DriveInfo(drive));
|
||||
}
|
||||
|
||||
// List of drives
|
||||
|
||||
@ -491,6 +491,25 @@ public class FilePanel extends JPanel {
|
||||
driveSet.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
// On Windows, additionally add mapped network drives if missed by listRoots
|
||||
if (MainApp.CURRENT_OS == MainApp.OS.WINDOWS) {
|
||||
javax.swing.filechooser.FileSystemView fsv = javax.swing.filechooser.FileSystemView.getFileSystemView();
|
||||
File[] fsvRoots = fsv.getRoots();
|
||||
if (fsvRoots != null) {
|
||||
for (File r : fsvRoots) {
|
||||
// This usually returns "Desktop". We need to look into it or other FSV methods.
|
||||
File[] devices = fsv.getFiles(r, false);
|
||||
if (devices != null) {
|
||||
for (File d : devices) {
|
||||
if (fsv.isDrive(d) || fsv.isFileSystemRoot(d)) {
|
||||
driveSet.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add home directory
|
||||
driveSet.add(new File(System.getProperty("user.home")));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user