]> git.street.me.uk Git - andy/viking.git/blobdiff - src/geotag_exif.c
Fix incorrectly updating files during geotagging that are read only.
[andy/viking.git] / src / geotag_exif.c
index 2dcb0fae1530e0d77484b996b5e19938ecbc3812..1a003938f62d21fb179c3416805e9dd61b496cb2 100644 (file)
@@ -37,6 +37,7 @@
 #include <ctype.h>
 #include <math.h>
 #include <glib/gi18n.h>
+#include <glib/gstdio.h>
 #include <libexif/exif-data.h>
 #include "libjpeg/jpeg-data.h"
 
@@ -156,18 +157,6 @@ VikWaypoint* a_geotag_create_waypoint_from_file ( const gchar *filename, VikCoor
        //if ( ! ( ee->data[0] == 2 && ee->data[2] == 0 && ee->data[3] == 0 ) )
        //      goto MyReturn;
 
-
-       ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_MAP_DATUM);
-       if ( ! ( ee && ee->components > 0 && ee->format == EXIF_FORMAT_ASCII ) )
-               goto MyReturn;
-
-       // If map datum specified - only deal in WGS-84 - the defacto standard
-       if ( ee && ee->components > 0 ) {
-               exif_entry_get_value ( ee, str, 128 );
-               if ( strncmp (str, "WGS-84", 6) )
-                       goto MyReturn;
-       }
-
        //
        // Lat & Long is necessary to form a waypoint.
        //
@@ -315,6 +304,15 @@ gchar* a_geotag_get_exif_date_from_file ( const gchar *filename, gboolean *has_G
        if ( !ed )
                return datetime;
 
+       // Also allows us to remember what directory we where using
+       gchar *dir = g_path_get_dirname ( filename );
+       if ( dir ) {
+               if ( g_chdir ( dir ) ) {
+                       g_warning ( "Could not change directory to %s", dir );
+               }
+               g_free (dir);
+       }
+
        gchar str[128];
        ExifEntry *ee;