42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* pwd.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */
|
|
/* Updated: 2023/02/21 15:11:38 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "./builtins_private.h"
|
|
|
|
int pwd(int fd)
|
|
{
|
|
char path[PATH_MAX];
|
|
|
|
if (getcwd(path, sizeof(path)) != NULL)
|
|
ft_putendl_fd(path, fd);
|
|
else
|
|
{
|
|
ft_putendl_fd("Error getcwd", fd);
|
|
return (1);
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
char *get_pwd(int fd)
|
|
{
|
|
char *str;
|
|
|
|
str = ft_calloc(PATH_MAX, sizeof(char *));
|
|
if (getcwd(str, PATH_MAX) != NULL)
|
|
return (str);
|
|
else
|
|
{
|
|
ft_putendl_fd("Error getcwd", fd);
|
|
return (NULL);
|
|
}
|
|
}
|