package org.studentrobotics.ide.checkout;

import java.io.File;
import java.io.FilenameFilter;

public class LinuxDrive {

	public String findPath() {
		// search /mnt/ and /media/*/
		System.err.println("a");
		File mnt = null;
		System.err.println("tag31");
		try {
			System.err.println("tag33");
			mnt = new File("/mnt/.srobo");
			System.err.println("tag32");

			if (mnt != null && mnt.exists()) {
				return "/mnt/";
			}

			File media = new File("/media/");
			if (media.isDirectory()) {
				// only get mountpoints from the media directory
				String[] directories = media.list(new FilenameFilter() {

					@Override
					public boolean accept(File arg0, String arg1) {
						return arg0.isDirectory();
					}
				});
				System.err.println("c");

				for (String s : directories) {
					File srobo = new File("/media/" + s + "/.srobo");

					if (srobo.exists()) {
						return "/media/" + s + "/";
					}

				}

			}
			System.err.println("b");
			return null;
		} catch (SecurityException se) {
			System.err.println("tag34");
			CheckoutApplet.hasDied = true;
			System.err.println("tag35");
			return null;
		}
	}

}

@@ -424,16 +424,127 @@
 ;%0A%09%09%09%7D%0A%0A
+%09%09%09String%5B%5D searchPaths = new String%5B%5D %7B %22/media/%22, %22/Volumes/%22 %7D;%0A%09%09%09for (String searchPath : searchPaths) %7B%0A%09
 %09%09%09File 
@@ -564,23 +564,25 @@
 ile(
-%22/media/%22
+searchPath
 );%0A%09%09%09
+%09
 if (
@@ -600,24 +600,25 @@
 ectory()) %7B%0A
+%09
 %09%09%09%09// only 
@@ -658,16 +658,17 @@
 rectory%0A
+%09
 %09%09%09%09Stri
@@ -726,16 +726,17 @@
 %7B%0A%0A%09%09%09%09%09
+%09
 @Overrid
@@ -737,16 +737,17 @@
 verride%0A
+%09
 %09%09%09%09%09pub
@@ -787,24 +787,25 @@
 ing arg1) %7B%0A
+%09
 %09%09%09%09%09%09return
@@ -834,18 +834,20 @@
 %09%09%09%09
+%09
 %7D%0A
+%09
 %09%09%09%09%7D);%0A
 %09%09%09%09
@@ -842,16 +842,17 @@
 %09%09%09%09%7D);%0A
+%09
 %09%09%09%09Syst
@@ -877,16 +877,17 @@
 );%0A%0A%09%09%09%09
+%09
 for (Str
@@ -910,24 +910,25 @@
 ies) %7B%0A%09%09%09%09%09
+%09
 File srobo =
@@ -937,25 +937,26 @@
 ew File(
-%22/media/%22
+searchPath
  + s + %22
@@ -962,25 +962,40 @@
 %22/.srobo%22);%0A
-%0A
+%09%09%09%09%09%09%0A%09%09%09%09%09%09%0A%0A%09
 %09%09%09%09%09if (sro
@@ -1005,24 +1005,25 @@
 exists()) %7B%0A
+%09
 %09%09%09%09%09%09return
@@ -1023,25 +1023,26 @@
 %09return 
-%22/media/%22
+searchPath
  + s + %22
@@ -1045,16 +1045,25 @@
  + %22/%22;%0A
+%09%09%09%09%09%09%7D%0A%0A
 %09%09%09%09%09%7D%0A%0A
@@ -1068,17 +1068,16 @@
 %0A%0A%09%09%09%09%7D%0A
-%0A
 %09%09%09%7D%0A%09%09%09

add support for the mac