summaryrefslogtreecommitdiffstats
path: root/src/ft_f_file.c
blob: 53e0c8b45dd8935fcdc01d9f0750069050257ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_f_file.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "ft_s_lcom.h"
#include "ft_s_destroy.h"

void
	ft_f_file(const char path[],
			t_msh *msh)
{
	if (errno == ENOENT)
	{
		ft_dprintf(STDERR_FILENO,
			"minishell: %s: No such file or directory\n", path);
	}
	else if (errno == EACCES)
	{
		ft_dprintf(STDERR_FILENO,
			"minishell: %s: Permission denied\n", path);
	}
	else if (errno == EISDIR)
	{
		ft_dprintf(STDERR_FILENO,
			"minishell: %s: Is a directory\n", path);
	}
	ft_lcom_clear(&msh->curr);
	ft_s_destroy(msh);
	exit(1);
}