[Tracker] Proposed patch: use '~' in the config file
- From: lbell <l bellonda virgilio it>
- To: tracker-list gnome org
- Subject: [Tracker] Proposed patch: use '~' in the config file
- Date: Thu, 08 Mar 2007 00:43:52 +0100
This is a proposed patch to convert paths beginning with ~ character to the real home dir path, so you can
write ~/Documents instead of /home/MyUser/Documents in the configuration file.
I used a brute force check with '~' character (maybe not so portable) and modified the original data while
loading.
Regards
Luca Bellonda
Index: tracker-utils.c
===================================================================
--- tracker-utils.c (revisione 537)
+++ tracker-utils.c (copia locale)
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
+#include <limits.h>
#include <glib/gprintf.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>
@@ -1699,33 +1700,72 @@
}
}
-
-
static GSList *
-array_to_list (char **array)
+check_dir_name ( GSList* list, char *input_name )
{
- GSList *list;
- int i;
+ int is_converted = FALSE;
+ if( '~' == input_name[0] ) {
+ const char* home_dir = g_get_home_dir ();
+ if( (NULL != home_dir) && (strlen (home_dir)>0) ) {
+ int is_separator = FALSE;
+ char * new_name ;
+ if( G_DIR_SEPARATOR == input_name[1] )
+ is_separator = TRUE;
+ else
+ if(G_DIR_SEPARATOR == home_dir[strlen(home_dir)-1] )
+ is_separator = TRUE;
+ new_name = g_strdup_printf ( "%s%s%s", home_dir, (is_separator? "":G_DIR_SEPARATOR_S),
&input_name[1] );
+ if( strlen(new_name)<=PATH_MAX) {
+ list = g_slist_prepend (list, new_name);
+ is_converted = TRUE;
+ }else
+ g_free(new_name);
+ }
+ }
+ if(!is_converted)
+ {
+ list = g_slist_prepend (list, g_strdup (input_name));
+ }
+ return list;
+}
- list = NULL;
+GSList *
+tracker_array_to_list (char **array)
+{
+ GSList *list;
+ int i;
- for (i = 0; array[i] != NULL; i++) {
- if (strlen (array[i]) > 0) {
- list = g_slist_prepend (list, g_strdup (array[i]));
- }
- }
+ list = NULL;
- g_strfreev (array);
+ for (i = 0; array[i] != NULL; i++) {
+ if (strlen (array[i]) > 0) {
+ list = check_dir_name( list, array[i]);
+ }
+ }
- return list;
+ g_strfreev (array);
+
+ return list;
}
+GSList *
+generic_array_to_list (char **array)
+{
+ GSList *list;
+ int i;
+ list = NULL;
-GSList *
-tracker_array_to_list (char **array)
-{
- return array_to_list (array);
+ for (i = 0; array[i] != NULL; i++) {
+ if (strlen (array[i]) > 0) {
+ list = g_slist_prepend (list, g_strdup (array[i]));
+ }
+ }
+
+ g_strfreev (array);
+
+ return list;
+
}
@@ -1921,7 +1961,6 @@
}
-
void
tracker_load_config_file ()
{
@@ -2026,7 +2065,7 @@
NULL);
if (values) {
- tracker->watch_directory_roots_list = array_to_list (values);
+ tracker->watch_directory_roots_list = tracker_array_to_list (values);
} else {
tracker->watch_directory_roots_list = g_slist_prepend (tracker->watch_directory_roots_list,
g_strdup (g_get_home_dir ()));
}
@@ -2038,7 +2077,7 @@
NULL);
if (values) {
- tracker->no_watch_directory_list = array_to_list (values);
+ tracker->no_watch_directory_list = tracker_array_to_list (values);
} else {
tracker->no_watch_directory_list = NULL;
@@ -2077,7 +2116,7 @@
NULL);
if (values) {
- tracker->no_index_file_types = array_to_list (values);
+ tracker->no_index_file_types = generic_array_to_list (values);
} else {
tracker->no_index_file_types = NULL;
}
@@ -2129,7 +2168,7 @@
additional_mboxes = g_key_file_get_string_list (key_file, "Emails",
"AdditionalMBoxesToIndex", NULL, NULL);
- tracker->additional_mboxes_to_index = array_to_list (additional_mboxes);
+ tracker->additional_mboxes_to_index = tracker_array_to_list (additional_mboxes);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]