X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosLib.java;h=6c1729dfc03a32a51f64f3d8fbf2eabf092ec652;hb=4c5acb57d7ac1abec7bb4cda9dc88c2a19767a2d;hp=355c7a27a9c337f71fca43e0dbfee9f58399b709;hpb=3d29882f5c70e627b0bbfe42c0a31d6cb5f6b6bf;p=fw%2Faltos diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 355c7a27..6c1729df 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -588,4 +588,28 @@ public class AltosLib { public static String igniter_name(int i) { return String.format("Ignitor %c", 'A' + i); } + + public static AltosRecordSet record_set(File file) throws FileNotFoundException, IOException { + FileInputStream in; + in = new FileInputStream(file); + if (file.getName().endsWith("telem")) { + return new AltosTelemetryFile(in); + } else if (file.getName().endsWith("eeprom")) { + return new AltosEepromFile(in); + } else { + String name = file.getName(); + int dot = name.lastIndexOf('.'); + String extension; + + if (dot == -1) + throw new IOException(String.format("%s (Missing extension)", file.toString())); + else { + extension = name.substring(dot); + throw new IOException(String.format("%s (Invalid extension '%s')", + file.toString(), + extension)); + } + } + } + }