X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2FGpsPrune.java;h=70e1c8e7858669816843165d5dfd386b006b62ed;hb=b361869e590bbca32664c16ac24d6296926594a5;hp=41dac2b0d0300538ecb9813bd8f71462e5b8c828;hpb=649c5da6ee1bbc590699e11a92316ece2ea8512d;p=GpsPrune.git diff --git a/tim/prune/GpsPrune.java b/tim/prune/GpsPrune.java index 41dac2b..70e1c8e 100644 --- a/tim/prune/GpsPrune.java +++ b/tim/prune/GpsPrune.java @@ -28,16 +28,16 @@ import tim.prune.gui.profile.ProfileChart; /** * GpsPrune is a tool to visualize, edit, convert and prune GPS data * Please see the included readme.txt or http://activityworkshop.net - * This software is copyright activityworkshop.net 2006-2011 and made available through the Gnu GPL version 2. + * This software is copyright activityworkshop.net 2006-2013 and made available through the Gnu GPL version 2. * For license details please see the included license.txt. * GpsPrune is the main entry point to the application, including initialisation and launch */ public class GpsPrune { /** Version number of application, used in about screen and for version check */ - public static final String VERSION_NUMBER = "13"; + public static final String VERSION_NUMBER = "14.1"; /** Build number, just used for about screen */ - public static final String BUILD_NUMBER = "240"; + public static final String BUILD_NUMBER = "265a"; /** Static reference to App object */ private static App APP = null; @@ -87,11 +87,13 @@ public class GpsPrune { // Check if a data file has been given File f = new File(arg); - if (f.exists() && f.canRead()) { + if (f.exists() && f.isFile() && f.canRead()) { dataFiles.add(f); } - else { - System.out.println("Unknown parameter '" + arg + "'."); + else + { + // Make a useful String from the unknown parameter - could it be a mistyped filename? + System.out.println(makeUnknownParameterString(arg)); showUsage = true; } } @@ -134,13 +136,15 @@ public class GpsPrune // If langfilename is blank on command line parameters then don't use setting from config langFilename = Config.getConfigString(Config.KEY_LANGUAGE_FILE); } - if (langFilename != null && !langFilename.equals("")) { + if (langFilename != null) + { try { I18nManager.addLanguageFile(langFilename); Config.setConfigString(Config.KEY_LANGUAGE_FILE, langFilename); } catch (FileNotFoundException fnfe) { System.err.println("Failed to load language file: " + langFilename); + Config.setConfigString(Config.KEY_LANGUAGE_FILE, ""); } } // Set up the window and go @@ -245,4 +249,29 @@ public class GpsPrune // Finally, give the files to load to the App APP.loadDataFiles(inDataFiles); } + + /** + * Try to guess whether it's a mistyped parameter or a mistyped filename + * @param inParam command line argument + * @return error message + */ + private static String makeUnknownParameterString(String inParam) + { + File file = new File(inParam); + if (file.exists()) + { + if (file.isDirectory()) return "'" + inParam + "' is a directory"; + if (!file.canRead()) return "Cannot read file '" + inParam + "'"; + return "Something wrong with file '" + inParam + "'"; + } + do + { + String name = file.getName(); + file = file.getParentFile(); + if (file != null && file.exists() && file.canRead()) return "Tried to load file '" + inParam + "' but cannot find '" + name + "'"; + } + while (file != null); + + return "Unknown parameter '" + inParam + "'"; + } }