char *ft_setpath ( char *path, const char *redirection ) { char *next; char *target; target = NULL; if (!(ft_strncmp(redirection, "..", 2) == 0)) { if (*redirection) { if (*(next = ft_strchr(path, '\0')) != *path) *next++ = '/'; next = ft_strcpy(next, redirection); } return (path); } else { next = path; if (ft_strchr(path, '/')) { while ((next = ft_strchr(next, '/'))) target = next++; } if (target) *(target) = '\0'; else *path = '\0'; return (ft_setpath(path, redirection + 3)); } }
int ft_flo(t_room *room, t_room *start, t_room *end, t_env *e) { t_lst *tmp; t_room *tmpr; tmp = NULL; ft_addqueue(start->name, &tmp, room, -2); while (tmp) { tmpr = ft_popqueue(room, &tmp); ft_addsons(room, &tmp, tmpr, ft_getidfromname(room, tmpr->name)); if (!ft_strcmp(tmpr->name, end->name)) break ; } if (ft_strcmp(tmpr->name, end->name)) return (0); ft_freelink(&tmp); ft_setpath(end, room, e); return (1); }