diff options
author | Stephan Merker <merker.stephan@googlemail.com> | 2011-09-28 22:00:16 +0200 |
---|---|---|
committer | Stephan Merker <merker.stephan@googlemail.com> | 2011-09-28 22:00:16 +0200 |
commit | 945fef72bfbb02a95aec9f6960854de7d7d19afe (patch) | |
tree | 91e6e19d6514307fc653604cfb857b159e844d7c /main/src/cgeo/geocaching/files | |
parent | 90141a1632dafe90e69abffa88690cf4b3886d01 (diff) | |
download | cgeo-945fef72bfbb02a95aec9f6960854de7d7d19afe.zip cgeo-945fef72bfbb02a95aec9f6960854de7d7d19afe.tar.gz cgeo-945fef72bfbb02a95aec9f6960854de7d7d19afe.tar.bz2 |
Improved getWaypointsFileForGpx()
Diffstat (limited to 'main/src/cgeo/geocaching/files')
-rw-r--r-- | main/src/cgeo/geocaching/files/GPXParser.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index f71b3ec..6ed294e 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -65,6 +65,8 @@ public abstract class GPXParser extends FileParser { */ private static final String GSAK_NS = "http://www.gsak.net/xmlv1/5"; + private static final String GPX_FILE_EXTENSION = ".gpx"; + private int listId = 1; final protected String namespace; final private String version; @@ -899,10 +901,9 @@ public abstract class GPXParser extends FileParser { // 1234567.gpx -> 1234567-wpts.gpx public static File getWaypointsFileForGpx(File file) { - String name = file.getName(); - int idx = name.lastIndexOf('.'); - if (idx > 0) { - String wptsName = name.substring(0, idx) + "-wpts" + name.substring(idx); + final String name = file.getName(); + if (StringUtils.endsWithIgnoreCase(name, GPX_FILE_EXTENSION) && (StringUtils.length(name) > GPX_FILE_EXTENSION.length())) { + String wptsName = StringUtils.substringBeforeLast(name, ".") + "-wpts" + StringUtils.right(name, GPX_FILE_EXTENSION.length()); return new File(file.getParentFile(), wptsName); } else { return null; |