+/**
+ * append_file_ext:
+ *
+ * Append a file extension, if not already present.
+ *
+ * Returns: a newly allocated string
+ */
+gchar *append_file_ext ( const gchar *filename, VikFileType_t type )
+{
+ gchar *new_name = NULL;
+ const gchar *ext = NULL;
+
+ /* Select an extension */
+ switch (type)
+ {
+ case FILE_TYPE_GPX:
+ ext = ".gpx";
+ break;
+ case FILE_TYPE_KML:
+ ext = ".kml";
+ break;
+ case FILE_TYPE_GEOJSON:
+ ext = ".geojson";
+ break;
+ case FILE_TYPE_GPSMAPPER:
+ case FILE_TYPE_GPSPOINT:
+ default:
+ /* Do nothing, ext already set to NULL */
+ break;
+ }
+
+ /* Do */
+ if ( ext != NULL && ! a_file_check_ext ( filename, ext ) )
+ new_name = g_strconcat ( filename, ext, NULL );
+ else
+ /* Simply duplicate */
+ new_name = g_strdup ( filename );
+
+ return new_name;
+}
+