altoslib: Create data file open helper in AltosLib
[fw/altos] / telegps / TeleGPS.java
index 5e500e0259a74623e6d934d2e85b876bc0107d2a..e032726a1dfadd268e8fd96582bfe386fca505c0 100644 (file)
@@ -620,21 +620,10 @@ public class TeleGPS
        }
 
        static AltosRecordSet record_set(File file) {
-               FileInputStream in;
-                if (file.getName().endsWith("telem")) {
-                        try {
-                                in = new FileInputStream(file);
-                                return new AltosTelemetryFile(in);
-                        } catch (Exception e) {
-                                System.out.printf("Failed to open file '%s'\n", file);
-                        }
-                } else {
-
-                        try {
-                                return new AltosEepromFile(new FileReader(file));
-                        } catch (Exception e) {
-                                System.out.printf("Failed to open file '%s'\n", file);
-                        }
+               try {
+                       return AltosLib.record_set(file);
+               } catch (IOException ie) {
+                       System.out.printf("%s\n", ie.getMessage());
                 }
                 return null;
        }