Changed the root package from net.sf.briar to org.briarproject.

This commit is contained in:
akwizgran
2014-01-08 16:18:30 +00:00
parent dce70f487c
commit 832476412c
427 changed files with 2507 additions and 2507 deletions

View File

@@ -0,0 +1,40 @@
package org.briarproject.plugins.file;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
abstract class UnixRemovableDriveFinder implements RemovableDriveFinder {
protected abstract String getMountCommand();
protected abstract String parseMountPoint(String line);
protected abstract boolean isRemovableDriveMountPoint(String path);
public List<File> findRemovableDrives() throws IOException {
List<File> drives = new ArrayList<File>();
Process p = new ProcessBuilder(getMountCommand()).start();
Scanner s = new Scanner(p.getInputStream(), "UTF-8");
try {
while(s.hasNextLine()) {
String line = s.nextLine();
String[] tokens = line.split(" ");
if(tokens.length < 3) continue;
// The general format is "/dev/foo on /bar/baz ..."
if(tokens[0].startsWith("/dev/") && tokens[1].equals("on")) {
// The path may contain spaces so we can't use tokens[2]
String path = parseMountPoint(line);
if(isRemovableDriveMountPoint(path)) {
File f = new File(path);
if(f.exists() && f.isDirectory()) drives.add(f);
}
}
}
} finally {
s.close();
}
return Collections.unmodifiableList(drives);
}
}