- if ( ! a_babel_convert_from ( VIK_TRW_LAYER(vtl), "-i kml", filename, NULL, NULL ) ) {
- // Probably want to remove the vtl, but I'm not sure how yet...
- xfclose(f);
- return LOAD_TYPE_GPSBABEL_FAILURE;
+ if ( ! ( success = a_babel_convert_from ( VIK_TRW_LAYER(vtl), "-i kml", filename, NULL, NULL ) ) ) {
+ load_answer = LOAD_TYPE_GPSBABEL_FAILURE;
+ }
+ }
+ // NB use a extension check first, as a GPX file header may have a Byte Order Mark (BOM) in it
+ // - which currently confuses our check_magic function
+ else if ( check_file_ext ( filename, ".gpx" ) || check_magic ( f, GPX_MAGIC ) ) {
+ if ( ! ( success = a_gpx_read_file ( VIK_TRW_LAYER(vtl), f ) ) ) {
+ load_answer = LOAD_TYPE_GPX_FAILURE;