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/04/18 12:59:25 by erey-bet ### ########.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", 2);
|
|
return (1);
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
char *get_pwd(void)
|
|
{
|
|
char *str;
|
|
|
|
str = ft_calloc(PATH_MAX, sizeof(char *));
|
|
if (getcwd(str, PATH_MAX) != NULL)
|
|
return (str);
|
|
else
|
|
{
|
|
ft_putendl_fd("Error getcwd", 2);
|
|
return (NULL);
|
|
}
|
|
}
|