file norming

This commit is contained in:
Tanguy MAZE
2020-02-01 16:02:38 +01:00
parent 2a2f5bd4d3
commit f0837247bd
11 changed files with 153 additions and 138 deletions

View File

@@ -6,35 +6,12 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/07 16:44:40 by tmaze #+# #+# */
/* Updated: 2020/01/26 22:17:48 by tmaze ### ########.fr */
/* Updated: 2020/02/01 15:32:59 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
char *check_path_slash_cd(char *exec)
{
int i;
struct stat info;
struct stat info2;
if (exec[0] == '/')
{
if ((i = access(exec, F_OK)) != 0)
return (put_error_cd(exec, "no such file or directory"));
if ((i = lstat(exec, &info)) != 0)
return (put_error_cd(exec, "can't determine info"));
if ((S_ISLNK(info.st_mode)
&& ((i = stat(exec, &info2)) != 0 || !S_ISDIR(info2.st_mode)))
&& !S_ISDIR(info.st_mode))
return (put_error_cd(exec, "not a directory"));
if ((i = access(exec, X_OK)) != 0)
return (put_error_cd(exec, "permission denied"));
return (exec);
}
return (NULL);
}
int cmd_cd_update_env(char *path, t_env **env, char opt)
{
t_env *pwd;