diff --git a/42sh/libft/src/sys/is_directory.c b/42sh/libft/src/sys/is_directory.c index accd92a4..98ca4bad 100644 --- a/42sh/libft/src/sys/is_directory.c +++ b/42sh/libft/src/sys/is_directory.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 01:40:31 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:42:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:58:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ int is_directory(const char *path) { struct stat path_stat; - stat(path, &path_stat); + if (stat(path, &path_stat) != 0) + return (0); return (S_ISDIR(path_stat.st_mode)); } diff --git a/42sh/libft/src/sys/try_access.c b/42sh/libft/src/sys/try_access.c index 79335cd4..3a48ac35 100644 --- a/42sh/libft/src/sys/try_access.c +++ b/42sh/libft/src/sys/try_access.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 01:10:56 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:36:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:58:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,10 +15,10 @@ int try_access(char *file, int exists, t_flag a_flag) { if (exists && access(file, F_OK) != 0) - return (ERR_SET(E_SYS_NOFILE, file) * 0 - 1); + return (ERR_SET(E_SYS_NOFILE, file)); else if (is_directory(file)) - return (ERR_SET(E_SYS_ISDIR, file) * 0 - 1); + return (ERR_SET(E_SYS_ISDIR, file)); else if (access(file, F_OK) == 0 && access(file, a_flag) != 0) - return (ERR_SET(E_SYS_NOPERM, file) * 0 - 1); + return (ERR_SET(E_SYS_NOPERM, file)); return (0); }