-
- for(action_cur = filtering->action_list ; action_cur != NULL ;
- action_cur = action_cur->next) {
-
- FilteringAction *action = action_cur->data;
-
- if (action->type == MATCHACTION_SET_TAG ||
- action->type == MATCHACTION_UNSET_TAG)
- continue;
- if (!action->destination)
- continue;
-
- destlen = strlen(action->destination);
-
- if (destlen > oldpathlen) {
- prefixlen = destlen - oldpathlen;
- suffix = action->destination + prefixlen;
-
- if (!strncmp(old_path, suffix, oldpathlen)) {
- prefix = g_malloc0(prefixlen + 1);
- strncpy2(prefix, action->destination, prefixlen);
-
- base = suffix + oldpathlen;
- while (*base == G_DIR_SEPARATOR) base++;
- if (*base == '\0')
- dest_path = g_strconcat(prefix,
- separator,
- new_path, NULL);
- else
- dest_path = g_strconcat(prefix,
- separator,
- new_path,
- separator,
- base, NULL);
-
- g_free(prefix);
- g_free(action->destination);
- action->destination = dest_path;
- matched = TRUE;
- } else { /* for non-leaf folders */
- /* compare with trailing slash */
- if (!strncmp(old_path_with_sep, action->destination, oldpathlen+1)) {
-
- suffix = action->destination + oldpathlen + 1;
- dest_path = g_strconcat(new_path,
- separator,
- suffix, NULL);
- g_free(action->destination);
- action->destination = dest_path;
- matched = TRUE;
- }
- }
- } else {
- /* folder-moving a leaf */
- if (!strcmp(old_path, action->destination)) {
- dest_path = g_strdup(new_path);
- g_free(action->destination);
- action->destination = dest_path;
- matched = TRUE;
- }
- }
- }