-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cbd052
commit d7c1517
Showing
10 changed files
with
296 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <libftp.h> | ||
|
||
int ft_wchdir(char *path) | ||
{ | ||
char *cwd; | ||
int n; | ||
|
||
n = 0; | ||
cwd = ft_wgetcwd(); | ||
if (path && cwd) | ||
{ | ||
if (!(n = chdir(path))) | ||
{ | ||
ft_set_environ("OLDPWD", cwd); | ||
} | ||
} | ||
return (n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# include <libftp.h> | ||
|
||
char *ft_path(char *name) | ||
{ | ||
if (name) | ||
{ | ||
if (ft_strlen(name) == 1) | ||
{ | ||
if (ft_strnequ(name, "~", 1)) | ||
{ | ||
return (ft_get_environ("HOME")); | ||
} | ||
else if (ft_strnequ(name, "-", 1)) | ||
{ | ||
return (ft_get_environ("OLDPWD")); | ||
} | ||
} | ||
else | ||
{ | ||
if (!ft_strchr(name, '/')) | ||
{ | ||
return (ft_strjoin("./", name)); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
name = ft_path("~"); | ||
} | ||
return (name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,54 @@ | ||
# include <ft_p.h> | ||
|
||
/* | ||
** Change the server directory | ||
*/ | ||
|
||
void ft_cd(char *buff, char *root_dir, char **argv) | ||
{ | ||
char *resp; | ||
char *path; | ||
|
||
resp = NULL; | ||
path = NULL; | ||
if (buff && root_dir && argv) | ||
{ | ||
|
||
/* | ||
** check if there is a second argument | ||
*/ | ||
|
||
if ((argv + 1)) | ||
{ | ||
|
||
/* | ||
** check path for ~ or - | ||
*/ | ||
|
||
path = ft_path(argv[1]); | ||
|
||
/* | ||
** attempt to chang the directory | ||
*/ | ||
|
||
if (!ft_wchdir(path)) | ||
{ | ||
resp = ft_strdup("COMPLETE"); | ||
} | ||
else | ||
{ | ||
resp = ft_strdup("INCOMPLETE"); | ||
} | ||
|
||
/* | ||
** set the buffer to be used for client response | ||
*/ | ||
|
||
ft_fill_buffer(buff, resp); | ||
} | ||
} | ||
else | ||
{ | ||
ft_err_quit("ft_cd fail"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.