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));
|
((JComponent) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
// Get list of available drives
|
// Get list of available drives
|
||||||
File[] roots = File.listRoots();
|
java.util.Set<File> driveSet = new java.util.LinkedHashSet<>();
|
||||||
List<DriveInfo> drives = new ArrayList<>();
|
|
||||||
|
|
||||||
for (File root : roots) {
|
File[] roots = File.listRoots();
|
||||||
drives.add(new DriveInfo(root));
|
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
|
// List of drives
|
||||||
|
|||||||
@ -492,6 +492,25 @@ public class FilePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Add home directory
|
||||||
driveSet.add(new File(System.getProperty("user.home")));
|
driveSet.add(new File(System.getProperty("user.home")));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user