equal
deleted
inserted
replaced
441 } |
441 } |
442 |
442 |
443 public boolean isFileSystemRoot(File dir) { |
443 public boolean isFileSystemRoot(File dir) { |
444 //Note: Removable drives don't "exist" but are listed in "My Computer" |
444 //Note: Removable drives don't "exist" but are listed in "My Computer" |
445 if (dir != null) { |
445 if (dir != null) { |
446 Win32ShellFolder2 drives = getDrives(); |
446 |
447 if (dir instanceof Win32ShellFolder2) { |
447 if (dir instanceof Win32ShellFolder2) { |
448 Win32ShellFolder2 sf = (Win32ShellFolder2)dir; |
448 Win32ShellFolder2 sf = (Win32ShellFolder2)dir; |
449 if (sf.isFileSystem()) { |
449 |
450 if (sf.parent != null) { |
450 return (sf.isFileSystem() && sf.parent != null && |
451 return sf.parent.equals(drives); |
451 sf.parent.equals(Win32ShellFolder2.listRoots())); |
452 } |
|
453 // else fall through ... |
|
454 } else { |
|
455 return false; |
|
456 } |
|
457 } |
452 } |
458 String path = dir.getPath(); |
453 String path = dir.getPath(); |
459 |
454 |
460 if (path.length() != 3 || path.charAt(1) != ':') { |
455 if (path.length() != 3 || path.charAt(1) != ':') { |
461 return false; |
456 return false; |
462 } |
457 } |
463 |
458 |
464 File[] files = drives.listFiles(); |
459 File[] roots = Win32ShellFolder2.listRoots(); |
465 |
460 |
466 return files != null && Arrays.asList(files).contains(dir); |
461 return roots != null && Arrays.asList(roots).contains(dir); |
467 } |
462 } |
468 return false; |
463 return false; |
469 } |
464 } |
470 |
465 |
471 private static List<Win32ShellFolder2> topFolderList = null; |
466 private static List<Win32ShellFolder2> topFolderList = null; |
559 */ |
554 */ |
560 Thread thread = new Thread( |
555 Thread thread = new Thread( |
561 ThreadGroupUtils.getRootThreadGroup(), comRun, name, |
556 ThreadGroupUtils.getRootThreadGroup(), comRun, name, |
562 0, false); |
557 0, false); |
563 thread.setDaemon(true); |
558 thread.setDaemon(true); |
|
559 /* This is important, since this thread running at lower priority |
|
560 leads to memory consumption when listDrives() function is called |
|
561 repeatedly. |
|
562 */ |
|
563 thread.setPriority(Thread.MAX_PRIORITY); |
564 return thread; |
564 return thread; |
565 }); |
565 }); |
566 return comThread; |
566 return comThread; |
567 } |
567 } |
568 |
568 |