Fix:Core:United *get_user_data_directory() functions with same body in navit.c
authortegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 7 Nov 2010 09:02:38 +0000 (09:02 +0000)
committertegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 7 Nov 2010 09:02:38 +0000 (09:02 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3655 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/bookmarks.c
navit/navit/navit.h
navit/navit/osd/core/osd_core.c
navit/navit/popup.c

index 73ba2dc..07fff8d 100644 (file)
@@ -215,8 +215,8 @@ bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *t
        //this_->attrs=attr_list_dup(attrs);
        this_->trans=trans;
 
-       this_->bookmark_file=g_strjoin(NULL, bookmarks_get_user_data_directory(TRUE), "/bookmark.txt", NULL);
-       this_->working_file=g_strjoin(NULL, bookmarks_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL);
+       this_->bookmark_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt", NULL);
+       this_->working_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL);
 
        this_->clipboard=g_new0(struct bookmark_item_priv,1);
 
@@ -348,29 +348,6 @@ bookmarks_store_bookmarks_to_file(struct bookmarks *this_,  int limit,int replac
 }
 
 /*
- * bookmarks_get_user_data_directory
- *
- * returns the directory used to store user data files (center.txt,
- * destination.txt, bookmark.txt, ...)
- *
- * arg: gboolean create: create the directory if it does not exist
- */
-char*
-bookmarks_get_user_data_directory(gboolean create) {
-       char *dir;
-       dir = getenv("NAVIT_USER_DATADIR");
-       if (create && !file_exists(dir)) {
-               dbg(0,"creating dir %s\n", dir);
-               if (file_mkdir(dir,0)) {
-                       dbg(0,"failed creating dir %s\n", dir);
-                       return NULL;
-               }
-       }
-
-       return dir;
-}
-
-/*
  * bookmarks_get_destination_file
  *
  * returns the name of the file used to store destinations with its
@@ -382,7 +359,7 @@ bookmarks_get_user_data_directory(gboolean create) {
 char*
 bookmarks_get_destination_file(gboolean create)
 {
-       return g_strjoin(NULL, bookmarks_get_user_data_directory(create), "/destination.txt", NULL);
+       return g_strjoin(NULL, navit_get_user_data_directory(create), "/destination.txt", NULL);
 }
 
 /*
@@ -397,7 +374,7 @@ bookmarks_get_destination_file(gboolean create)
 char*
 bookmarks_get_center_file(gboolean create)
 {
-       return g_strjoin(NULL, bookmarks_get_user_data_directory(create), "/center.txt", NULL);
+       return g_strjoin(NULL, navit_get_user_data_directory(create), "/center.txt", NULL);
 }
 
 void
index 5fcfc0f..8a7e66f 100644 (file)
@@ -87,6 +87,7 @@ void navit_set_center_cursor(struct navit *this_, int keep_orientation, int auto
 void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout);
 int navit_set_attr(struct navit *this_, struct attr *attr);
 int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+char* navit_get_user_data_directory(int create);
 int navit_add_attr(struct navit *this_, struct attr *attr);
 int navit_remove_attr(struct navit *this_, struct attr *attr);
 struct attr_iter *navit_attr_iter_new(void);
index 16357f9..5fc36b8 100644 (file)
@@ -376,30 +376,6 @@ osd_odometer_init(struct odometer *this, struct navit *nav)
        osd_odometer_draw(this, nav, NULL);
 }
 
-/*
- * osd_get_user_data_directory
- *
- * returns the directory used to store user data files (center.txt,
- * destination.txt, bookmark.txt, ...)
- *
- * arg: gboolean create: create the directory if it does not exist
- */
-char*
-osd_get_user_data_directory(gboolean create) {
-       char *dir;
-       dir = getenv("NAVIT_USER_DATADIR");
-       if (create && !file_exists(dir)) {
-               dbg(0,"creating dir %s\n", dir);
-               if (file_mkdir(dir,0)) {
-                       dbg(0,"failed creating dir %s\n", dir);
-                       return NULL;
-               }
-       }
-
-       return dir;
-}
-
-
 static void 
 osd_odometer_destroy(struct navit* nav)
 {
@@ -408,7 +384,7 @@ osd_odometer_destroy(struct navit* nav)
                odometers_saved = 1;
                //save odometers that are persistent(ie have name)
                GList* list = odometer_list;
-               char* fn = g_strdup_printf("%s/odometer.txt",osd_get_user_data_directory(TRUE));
+               char* fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(TRUE));
                f = fopen(fn,"w+");
                g_free(fn);
                if(!f) {
@@ -474,7 +450,7 @@ osd_odometer_new(struct navit *nav, struct osd_methods *meth,
 
        //load state from file
        FILE* f;
-       char* fn = g_strdup_printf("%s/odometer.txt",osd_get_user_data_directory(FALSE));
+       char* fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(FALSE));
        f = fopen(fn,"r+");
 
        if(f) {
index 8d20d2e..7d0055d 100644 (file)
@@ -61,35 +61,11 @@ popup_set_no_passing(struct popup_item *item, void *param)
 
 #endif
 
-/**
- * @brief      Get the user data directory.
- * @param[in]   create - create the directory if it does not exist
- *
- * @return     char * to the data directory string.
- *
- * returns the directory used to store user data files (center.txt,
- * destination.txt, bookmark.txt, ...)
- *
- */
-char*
-popup_get_user_data_directory(gboolean create) {
-       char *dir;
-       dir = getenv("NAVIT_USER_DATADIR");
-       if (create && !file_exists(dir)) {
-               dbg(0,"creating dir %s\n", dir);
-               if (file_mkdir(dir,0)) {
-                       dbg(0,"failed creating dir %s\n", dir);
-                       return NULL;
-               }
-       }
-       return dir;
-} /* end: popup_get_user_data_directory(gboolean create) */
-
 static void
 popup_traffic_distortion(struct item *item, char *attr)
 {
        /* add the configuration directory to the name of the file to use */
-       char *dist_filename = g_strjoin(NULL, popup_get_user_data_directory(TRUE),
+       char *dist_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE),
                                                                        "/distortion.txt", NULL);
        if (dist_filename)                                      /* if we built the filename */
        {