jamie ha scritto:
thanks but would it not be simpler to use the posix realpath? (man
realpath for info)
I am not sure if it converts "~" for us as well as allowing relative
paths?
feel free to resubmit patch using realpath if it does. If not can you
also include realpath anyhow
Ok, this is the patch including realpath and some debugging info. I leaved
'~' handling,
it is invisible if you don't prefix a name with tilde.
bye
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,84 @@
}
}
+static GSList *
+check_dir_name ( GSList* list, char *input_name )
+{
+ tracker_debug ("checking dir names : %s", input_name );
+ 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( ( NULL!= new_name ) && (strlen(new_name)<=PATH_MAX) ) {
+ char resolved_name[PATH_MAX+2];
+ if( realpath (new_name, resolved_name) != NULL )
+ list = g_slist_prepend (list, g_strdup
(resolved_name));
+ else
+ list = g_slist_prepend (list, g_strdup (new_name));
+ is_converted = TRUE;
+ }
+ if( NULL!= new_name )
+ g_free (new_name);
+ }
+ }
+ if(!is_converted)
+ {
+ char resolved_name[PATH_MAX+2];
+ if( realpath (input_name, resolved_name) != NULL )
+ list = g_slist_prepend (list, g_strdup (resolved_name));
+ else
+ list = g_slist_prepend (list, g_strdup (input_name));
+ }
+ tracker_debug ("resolved to %s\n", list->data );
+ return list;
+}
-static GSList *
-array_to_list (char **array)
+GSList *
+tracker_array_to_list (char **array)
{
- GSList *list;
- int i;
+ GSList *list;
+ int i;
- list = NULL;
+ list = NULL;
- for (i = 0; array[i] != NULL; i++) {
- if (strlen (array[i]) > 0) {
- list = g_slist_prepend (list, g_strdup (array[i]));
- }
- }
+ for (i = 0; array[i] != NULL; i++) {
+ if (strlen (array[i]) > 0) {
+ list = check_dir_name( list, array[i]);
+ }
+ }
- g_strfreev (array);
+ g_strfreev (array);
- return list;
+ 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 +1973,6 @@
}
-
void
tracker_load_config_file ()
{
@@ -2026,7 +2077,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 +2089,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 +2128,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 +2180,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);
}
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list