Directory patch

View: New views
1 Messages — Rating Filter:   Alert me  

Directory patch

by Paul Martin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm finding that my SAV files and the autosaved GPX files are ending up in
my home directory.

My gpsdriverc has the following in it.

| mapdir = /home/pm/.gpsdrive/maps/
| trackdir = /home/pm/gps
| routedir = /home/pm/gps

I suggest the following patch. If (by a miracle or otherwise) the trackdir
does get stored with a trailing slash, the patch has no harmful effect as
two slashes are treated as one on Unix platforms.

--
Paul Martin <pm@...>


diff -ur gpsdrive-trunk/src/track.c gpsdrive-changed/src/track.c
--- gpsdrive-trunk/src/track.c 2009-01-16 11:59:24.651494858 +0000
+++ gpsdrive-changed/src/track.c 2009-06-21 19:19:54.239420272 +0100
@@ -97,7 +97,7 @@
  G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (fdialog));
 
  g_strlcpy (buf, local_config.dir_tracks, sizeof (buf));
- g_strlcat (buf, "track*.sav", sizeof (buf));
+ g_strlcat (buf, "/track*.sav", sizeof (buf));
 
  gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fdialog), buf);
 
@@ -357,7 +357,7 @@
       i = 0;
       do
  {
-  g_snprintf (buff, sizeof (buff), "%strack_%s_%03d.sav",
+  g_snprintf (buff, sizeof (buff), "%s/track_%s_%03d.sav",
    local_config.dir_tracks, datestring ,i++);
   e = stat (buff, &sbuf);
  }
@@ -368,6 +368,7 @@
 
   /* save in new file */
   g_strlcpy (filename_track, local_config.dir_tracks, sizeof (filename_track));
+  g_strlcat (filename_track, "/", sizeof (filename_track));
   g_strlcat (filename_track, savetrackfn, sizeof (filename_track));
   if ( mydebug > 11 )
       g_print ("savetrack(%d,%s)\n", mode,filename_track);
@@ -402,7 +403,7 @@
 
   /* append to existing backup file */
   g_strlcpy (filename_track, local_config.dir_tracks, sizeof (filename_track));
-  g_strlcat (filename_track, "track-ALL.sav", sizeof (filename_track));
+  g_strlcat (filename_track, "/track-ALL.sav", sizeof (filename_track));
   st = fopen (filename_track, "a");
   if (st == NULL)
     {
@@ -449,7 +450,7 @@
     
     if ((trackcoordnr % 30) == 29) { /* RNM: append to existing incremental file every 30 seconds */
  g_strlcpy (mappath, local_config.dir_tracks, sizeof (mappath));
- g_strlcat (mappath, "incremental.sav", sizeof(mappath));
+ g_strlcat (mappath, "/incremental.sav", sizeof(mappath));
  st = fopen (mappath, "a");
                 if (st == NULL) {
     st = fopen (mappath, "w");
@@ -495,7 +496,7 @@
  time (&t);
  ts = localtime (&t);
 
- g_snprintf (t_buf, sizeof (t_buf), "%s%s_%d%02d%02d_%02d%02d.gpx",
+ g_snprintf (t_buf, sizeof (t_buf), "%s/%s_%d%02d%02d_%02d%02d.gpx",
  local_config.dir_tracks, local_config.track_autoprefix,
  ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday, ts->tm_hour, ts->tm_min);
 


_______________________________________________
GPSdrive mailing list
GPSdrive@...
http://lists.gpsdrivers.org/mailman/listinfo/gpsdrive