Skip to content

Commit

Permalink
Merge branch 'client'
Browse files Browse the repository at this point in the history
  • Loading branch information
afullstopdot committed Jul 30, 2017
2 parents ba4bfbb + e26d387 commit a78ec41
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
4 changes: 1 addition & 3 deletions libftp/src/environ.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
28 changes: 26 additions & 2 deletions libftp/src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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));
}
2 changes: 1 addition & 1 deletion libftp/src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 3 additions & 3 deletions src/client/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
1 change: 1 addition & 0 deletions src/client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/server/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a78ec41

Please sign in to comment.