From 15fd38eff52e0d7a3c8d85d95c512c39ed35c5b8 Mon Sep 17 00:00:00 2001 From: Aymen Kh Date: Fri, 7 Jun 2019 02:27:29 -0700 Subject: [PATCH] Latest Update --- Includes/libft.h | 3 ++- Includes/macros_42.h | 7 ++++++- Includes/unistd_42.h | 3 ++- Makefile | 3 ++- Unistd/ft_basename.c | 24 ++++++++++++++++++++++++ Vector/vector_from.c | 2 +- 6 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 Unistd/ft_basename.c diff --git a/Includes/libft.h b/Includes/libft.h index 7368cf2..5d13a58 100755 --- a/Includes/libft.h +++ b/Includes/libft.h @@ -6,7 +6,7 @@ /* By: akharrou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/17 16:20:29 by akharrou #+# #+# */ -/* Updated: 2019/05/27 11:26:43 by akharrou ### ########.fr */ +/* Updated: 2019/06/07 02:25:48 by akharrou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -68,6 +68,7 @@ # include # include # include +# include /* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** diff --git a/Includes/macros_42.h b/Includes/macros_42.h index a80ab9f..4b118fd 100755 --- a/Includes/macros_42.h +++ b/Includes/macros_42.h @@ -6,7 +6,7 @@ /* By: akharrou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/04 09:07:32 by akharrou #+# #+# */ -/* Updated: 2019/06/01 15:48:00 by akharrou ### ########.fr */ +/* Updated: 2019/06/07 02:26:33 by akharrou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,6 +20,7 @@ # include # include +# include /* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** @@ -177,6 +178,10 @@ ** Convenient Macro(s). */ +# ifndef PASS +# define PASS (1) +# endif + # ifndef INT # define INT(c, base) (ft_strchr(base, c) - base) # endif diff --git a/Includes/unistd_42.h b/Includes/unistd_42.h index 2bdde94..a19ac26 100644 --- a/Includes/unistd_42.h +++ b/Includes/unistd_42.h @@ -6,7 +6,7 @@ /* By: akharrou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/27 10:12:47 by akharrou #+# #+# */ -/* Updated: 2019/06/05 17:04:23 by akharrou ### ########.fr */ +/* Updated: 2019/06/07 02:26:57 by akharrou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,7 @@ t_vector ft_getdirents(DIR *dirdes); t_vector ft_getdirentries(const char dirname[MAX_PATHLEN + 1]); +void ft_basename(const char *path, char *basename); /* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** diff --git a/Makefile b/Makefile index b5ab251..951d3ef 100755 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: akharrou +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2019/02/17 16:23:01 by akharrou #+# #+# # -# Updated: 2019/06/05 18:19:09 by akharrou ### ########.fr # +# Updated: 2019/06/07 02:27:09 by akharrou ### ########.fr # # # # **************************************************************************** # @@ -262,6 +262,7 @@ STRING = String/ft_strlen.c \ UNISTD = Unistd/ft_getdirentries.c \ Unistd/ft_getdirents.c \ + Unistd/ft_basename.c \ # — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — diff --git a/Unistd/ft_basename.c b/Unistd/ft_basename.c new file mode 100644 index 0000000..3185dc0 --- /dev/null +++ b/Unistd/ft_basename.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_basename.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: akharrou +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/06/07 02:23:57 by akharrou #+# #+# */ +/* Updated: 2019/06/07 02:26:36 by akharrou ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../Includes/string_42.h" +#include "../Includes/macros_42.h" + +void ft_basename(const char *path, char *basename) +{ + char **strtab; + + strtab = ft_strsplit(path, "/"); + ft_strncpy( + basename, strtab[ft_strtablen((const char**)strtab) - 1], MAX_NAMELEN); + freestrtab(&strtab); +} diff --git a/Vector/vector_from.c b/Vector/vector_from.c index 7f48416..92ee9ef 100644 --- a/Vector/vector_from.c +++ b/Vector/vector_from.c @@ -6,7 +6,7 @@ /* By: akharrou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/06/05 17:40:15 by akharrou #+# #+# */ -/* Updated: 2019/06/06 23:18:10 by akharrou ### ########.fr */ +/* Updated: 2019/06/07 02:27:20 by akharrou ### ########.fr */ /* */ /* ************************************************************************** */