diff --git a/libftp/src/environ.c b/libftp/src/environ.c index b7ac384..763a440 100644 --- a/libftp/src/environ.c +++ b/libftp/src/environ.c @@ -39,9 +39,7 @@ char *search_environ(char *curr, char *target) */ if (ft_strequ(name, target)) - { - - + { /* ** create new string with value prefixed by the '=' delimete */ diff --git a/libftp/src/path.c b/libftp/src/path.c index a0a38ae..923ab44 100644 --- a/libftp/src/path.c +++ b/libftp/src/path.c @@ -46,6 +46,15 @@ char *ft_path(char *name) ft_strdel(&home); return (joined); } + else if (!(ft_strequ(name,"./..") == 1) && !(ft_strnequ(name,"./",1) == 1)) + { + home = ft_get_environ("PWD"); + joined = ft_strjoin(home,"/"); + ft_strdel(&home); + home = ft_strjoin(joined,name); + ft_strdel(&joined); + return (home); + } } } else @@ -81,7 +90,7 @@ char *ft_lpath(char *name) { if (!ft_strchr(name, '/')) { - return (ft_path(ft_strjoin("./", name))); + return (ft_lpath(ft_strjoin("./", name))); } else if (ft_strnequ(name, "~/", 1) == 1) { @@ -97,11 +106,26 @@ char *ft_lpath(char *name) ft_strdel(&home); return (joined); } + else if (!(ft_strequ(name,"./..") == 1) && !(ft_strnequ(name,"./",1) == 1)) + { + home = ft_wgetcwd(); + joined = ft_strnew(ft_strlen(home)); + ft_strncpy(joined,home,ft_strlen(home) - 1); + ft_putstr(joined); + ft_strdel(&home); + home = ft_strdup(joined); + ft_strdel(&joined); + joined = ft_strjoin(home,"/"); + ft_strdel(&home); + home = ft_strjoin(joined,name); + ft_strdel(&joined); + return (home); + } } } else { name = ft_lpath("~"); } - return (name); + return (ft_strdup(name)); } \ No newline at end of file diff --git a/libftp/src/prompt.c b/libftp/src/prompt.c index f422152..677e42c 100644 --- a/libftp/src/prompt.c +++ b/libftp/src/prompt.c @@ -18,7 +18,7 @@ void ft_display_prompt(void) if (getcwd(cwd, 255)) { - ft_putstr("\033[0;35m("); + ft_putstr("\033[0;35m(\033[0m\033[0;40mLOCAL\033[0m\033[0;35m"); ft_putstr(cwd); ft_putstr(")$ \033[0m"); } diff --git a/src/client/lcd.c b/src/client/lcd.c index c6765a5..8d8ed22 100644 --- a/src/client/lcd.c +++ b/src/client/lcd.c @@ -24,11 +24,11 @@ void ft_lcd(int fd, char **argv) */ if (!ft_wchdir(path)) { - ft_send_response("ft_p: local directory changed.", fd); + ft_send_response("ft_p: \033[0;32mLOCAL directory changed\n\033[0m", fd); } else { - ft_send_response("ft_p: failed to change local directory.", fd); + ft_send_response("ft_p: \033[0;31mfailed to change LOCAL directory\n\033[0m", fd); } /* ** free path @@ -38,6 +38,6 @@ void ft_lcd(int fd, char **argv) } else { - ft_send_response("ft_p: failed to change local directory.", fd); + ft_send_response("ft_p: \033[0;31mfailed to change LOCAL directory\n\033[0m", fd); } } \ No newline at end of file diff --git a/src/client/main.c b/src/client/main.c index c29f921..cd85ce5 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -54,6 +54,7 @@ int main(int argc, char **argv) /* ** we are now connected to server, display client prompt */ + ft_init_environ(); ft_display_prompt(); /* ** read from stdin diff --git a/src/server/cd.c b/src/server/cd.c index da7a25b..230daea 100644 --- a/src/server/cd.c +++ b/src/server/cd.c @@ -27,7 +27,7 @@ void ft_cd(int fd, char **argv) /* ** check for Exiting Servers Home directory */ - if (!(ft_strequ(pwd, home) == 1 && ft_strequ(path, "./..") == 1)) + if (!(ft_strnequ(pwd, home,ft_strlen(pwd) - 2) == 1 && ft_strequ(path, "./..") == 1)) { /* ** removing spaces/newlines