mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Changed the root package from net.sf.briar to org.briarproject.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package org.briarproject.plugins.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
|
||||
class WindowsRemovableDriveFinder implements RemovableDriveFinder {
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364939.aspx
|
||||
private static final int DRIVE_REMOVABLE = 2;
|
||||
|
||||
public Collection<File> findRemovableDrives() throws IOException {
|
||||
File[] roots = File.listRoots();
|
||||
if(roots == null) throw new IOException();
|
||||
List<File> drives = new ArrayList<File>();
|
||||
for(File root : roots) {
|
||||
try {
|
||||
int type = Kernel32.INSTANCE.GetDriveType(root.getPath());
|
||||
if(type == DRIVE_REMOVABLE) drives.add(root);
|
||||
} catch(RuntimeException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(drives);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user