create dir in libft

This commit is contained in:
Antoine Riard 2017-03-25 04:13:45 +01:00
parent 8ecbab8a3b
commit 224689b62b

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 03:18:18 by ariard #+# #+# */ /* Created: 2017/03/25 03:18:18 by ariard #+# #+# */
/* Updated: 2017/03/25 04:07:10 by ariard ### ########.fr */ /* Updated: 2017/03/25 04:13:15 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,20 +16,21 @@ char *create_directory(const char *path, const char *old_pathnames)
{ {
char *new_pathnames; char *new_pathnames;
char *newdir; char *newdir;
char *temp;
char *semi; char *semi;
new_pathnames = ft_strdup(old_pathnames); new_pathnames = ft_strdup(old_pathnames);
temp = new_pathnames; temp = new_pathnames;
while (new_pathnames) while (new_pathnames)
{ {
if ((semi = ft_strchr(new_pathnames, ":"))) if ((semi = ft_strchr(new_pathnames, ':')))
*semi = 0; *semi = 0;
if (!is_directory(newdir = ft_str3join(new_pathnames, "/", path))) if (!is_directory(newdir = ft_str3join(new_pathnames, "/", path)))
ft_strdel(&newdir); ft_strdel(&newdir);
else else
break; break;
new_pathnames += new_pathnames + 1; new_pathnames += ft_strlen(new_pathnames) + 1;
} }
ft_strdel(temp); ft_strdel(&temp);
return (newdir); return (newdir);
} }