blob: 4689e53541891670845d46d381dc4b8a6c897199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package lombok.installer;
import java.util.ArrayList;
import java.util.List;
public class WindowsDriveInfo {
public List<String> getLogicalDrives() {
int flags = getLogicalDrives0();
flags = (flags & 0xFF) << 24 |
((flags >> 8) & 0xFF) << 16 |
((flags >> 16) & 0xFF) << 8 |
(flags >> 24) & 0xFF;
List<String> letters = new ArrayList<String>();
for ( int i = 0 ; i < 26 ; i++ ) {
if ( (flags & (1 << i)) != 0 ) letters.add(Character.toString((char)('A' + i)));
}
return letters;
}
private native int getLogicalDrives0();
public boolean isFixedDisk(String letter) {
return getDriveType(letter.toUpperCase() + ":\\") == 3L;
}
private native int getDriveType(String name);
}
|