A lot of edit but adding the struct (Yes, i just use parameters of the function util now, See u morrow)
This commit is contained in:
parent
9c4dfafdf7
commit
56655f5426
15 changed files with 403 additions and 30 deletions
35
sources/ft_pwd.c
Normal file
35
sources/ft_pwd.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_pwd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/31 22:14:33 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:27:33 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void ft_pwd(void)
|
||||
{
|
||||
t_str str;
|
||||
t_usize size;
|
||||
|
||||
size = 1024;
|
||||
str = (t_str)ft_calloc((size + 1), sizeof(t_i8));
|
||||
if (str == NULL)
|
||||
ft_exit(NULL, 0);
|
||||
while (getcwd(str, size) == NULL) {
|
||||
if (str)
|
||||
free(str);
|
||||
size *= 2;
|
||||
str = (t_str)ft_calloc(sizeof(t_i8), size);
|
||||
if (str == NULL) {
|
||||
ft_exit(NULL, 0);
|
||||
}
|
||||
}
|
||||
printf("%s\n", str);
|
||||
free(str);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue