mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Whitespace-only code formatting changes.
This commit is contained in:
@@ -53,24 +53,24 @@ class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
|
||||
public void run() {
|
||||
try {
|
||||
Collection<File> drives = finder.findRemovableDrives();
|
||||
while(running) {
|
||||
while (running) {
|
||||
pollingLock.lock();
|
||||
try {
|
||||
stopPolling.await(pollingInterval, MILLISECONDS);
|
||||
} finally {
|
||||
pollingLock.unlock();
|
||||
}
|
||||
if(!running) return;
|
||||
if (!running) return;
|
||||
Collection<File> newDrives = finder.findRemovableDrives();
|
||||
for(File f : newDrives) {
|
||||
if(!drives.contains(f)) callback.driveInserted(f);
|
||||
for (File f : newDrives) {
|
||||
if (!drives.contains(f)) callback.driveInserted(f);
|
||||
}
|
||||
drives = newDrives;
|
||||
}
|
||||
} catch(InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warning("Interrupted while waiting to poll");
|
||||
Thread.currentThread().interrupt();
|
||||
} catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
callback.exceptionThrown(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,16 +67,16 @@ implements RemovableDriveMonitor.Callback {
|
||||
try {
|
||||
List<File> drives =
|
||||
new ArrayList<File>(finder.findRemovableDrives());
|
||||
if(drives.isEmpty()) return null;
|
||||
if (drives.isEmpty()) return null;
|
||||
String[] paths = new String[drives.size()];
|
||||
for(int i = 0; i < paths.length; i++) {
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
paths[i] = drives.get(i).getPath();
|
||||
}
|
||||
int i = callback.showChoice(paths, "REMOVABLE_DRIVE_CHOOSE_DRIVE");
|
||||
if(i == -1) return null;
|
||||
if (i == -1) return null;
|
||||
return drives.get(i);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -95,29 +95,29 @@ implements RemovableDriveMonitor.Callback {
|
||||
protected Collection<File> findFilesByName(String filename) {
|
||||
List<File> matches = new ArrayList<File>();
|
||||
try {
|
||||
for(File drive : finder.findRemovableDrives()) {
|
||||
for (File drive : finder.findRemovableDrives()) {
|
||||
File[] files = drive.listFiles();
|
||||
if(files != null) {
|
||||
for(File f : files) {
|
||||
if(f.isFile() && filename.equals(f.getName()))
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
if (f.isFile() && filename.equals(f.getName()))
|
||||
matches.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
return Collections.unmodifiableList(matches);
|
||||
}
|
||||
|
||||
public void driveInserted(File root) {
|
||||
File[] files = root.listFiles();
|
||||
if(files != null) {
|
||||
for(File f : files) if(f.isFile()) createReaderFromFile(f);
|
||||
if (files != null) {
|
||||
for (File f : files) if (f.isFile()) createReaderFromFile(f);
|
||||
}
|
||||
}
|
||||
|
||||
public void exceptionThrown(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,18 +31,18 @@ public class RemovableDrivePluginFactory implements SimplexPluginFactory {
|
||||
public SimplexPlugin createPlugin(SimplexPluginCallback callback) {
|
||||
RemovableDriveFinder finder;
|
||||
RemovableDriveMonitor monitor;
|
||||
if(OsUtils.isLinux()) {
|
||||
if (OsUtils.isLinux()) {
|
||||
finder = new LinuxRemovableDriveFinder();
|
||||
monitor = new LinuxRemovableDriveMonitor();
|
||||
} else if(OsUtils.isMacLeopardOrNewer()) {
|
||||
} else if (OsUtils.isMacLeopardOrNewer()) {
|
||||
finder = new MacRemovableDriveFinder();
|
||||
monitor = new MacRemovableDriveMonitor();
|
||||
} else if(OsUtils.isMac()) {
|
||||
} else if (OsUtils.isMac()) {
|
||||
// JNotify requires OS X 10.5 or newer, so we have to poll
|
||||
finder = new MacRemovableDriveFinder();
|
||||
monitor = new PollingRemovableDriveMonitor(ioExecutor, finder,
|
||||
POLLING_INTERVAL);
|
||||
} else if(OsUtils.isWindows()) {
|
||||
} else if (OsUtils.isWindows()) {
|
||||
finder = new WindowsRemovableDriveFinder();
|
||||
monitor = new PollingRemovableDriveMonitor(ioExecutor, finder,
|
||||
POLLING_INTERVAL);
|
||||
|
||||
@@ -18,17 +18,17 @@ abstract class UnixRemovableDriveFinder implements RemovableDriveFinder {
|
||||
Process p = new ProcessBuilder(getMountCommand()).start();
|
||||
Scanner s = new Scanner(p.getInputStream(), "UTF-8");
|
||||
try {
|
||||
while(s.hasNextLine()) {
|
||||
while (s.hasNextLine()) {
|
||||
String line = s.nextLine();
|
||||
String[] tokens = line.split(" ");
|
||||
if(tokens.length < 3) continue;
|
||||
if (tokens.length < 3) continue;
|
||||
// The general format is "/dev/foo on /bar/baz ..."
|
||||
if(tokens[0].startsWith("/dev/") && tokens[1].equals("on")) {
|
||||
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)) {
|
||||
if (isRemovableDriveMountPoint(path)) {
|
||||
File f = new File(path);
|
||||
if(f.exists() && f.isDirectory()) drives.add(f);
|
||||
if (f.exists() && f.isDirectory()) drives.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ JNotifyListener {
|
||||
try {
|
||||
Class.forName("net.contentobjects.jnotify.JNotify");
|
||||
return null;
|
||||
} catch(UnsatisfiedLinkError e) {
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
return e;
|
||||
} catch(ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,11 @@ JNotifyListener {
|
||||
public static void checkEnabled() throws IOException {
|
||||
staticSynchLock.lock();
|
||||
try {
|
||||
if(!triedLoad) {
|
||||
if (!triedLoad) {
|
||||
loadError = tryLoad();
|
||||
triedLoad = true;
|
||||
}
|
||||
if(loadError != null) throw new IOException(loadError.toString());
|
||||
if (loadError != null) throw new IOException(loadError.toString());
|
||||
} finally {
|
||||
staticSynchLock.unlock();
|
||||
}
|
||||
@@ -57,8 +57,8 @@ JNotifyListener {
|
||||
checkEnabled();
|
||||
List<Integer> watches = new ArrayList<Integer>();
|
||||
int mask = JNotify.FILE_CREATED;
|
||||
for(String path : getPathsToWatch()) {
|
||||
if(new File(path).exists())
|
||||
for (String path : getPathsToWatch()) {
|
||||
if (new File(path).exists())
|
||||
watches.add(JNotify.addWatch(path, mask, false, this));
|
||||
}
|
||||
synchLock.lock();
|
||||
@@ -87,7 +87,7 @@ JNotifyListener {
|
||||
} finally {
|
||||
synchLock.unlock();
|
||||
}
|
||||
for(Integer w : watches) JNotify.removeWatch(w);
|
||||
for (Integer w : watches) JNotify.removeWatch(w);
|
||||
}
|
||||
|
||||
public void fileCreated(int wd, String rootPath, String name) {
|
||||
@@ -98,7 +98,7 @@ JNotifyListener {
|
||||
} finally {
|
||||
synchLock.unlock();
|
||||
}
|
||||
if(callback != null)
|
||||
if (callback != null)
|
||||
callback.driveInserted(new File(rootPath + "/" + name));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ class WindowsRemovableDriveFinder implements RemovableDriveFinder {
|
||||
|
||||
public Collection<File> findRemovableDrives() throws IOException {
|
||||
File[] roots = File.listRoots();
|
||||
if(roots == null) throw new IOException();
|
||||
if (roots == null) throw new IOException();
|
||||
List<File> drives = new ArrayList<File>();
|
||||
for(File root : roots) {
|
||||
for (File root : roots) {
|
||||
try {
|
||||
int type = Kernel32.INSTANCE.GetDriveType(root.getPath());
|
||||
if(type == DRIVE_REMOVABLE) drives.add(root);
|
||||
} catch(RuntimeException e) {
|
||||
if (type == DRIVE_REMOVABLE) drives.add(root);
|
||||
} catch (RuntimeException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user