diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-26 02:54:05 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-26 02:54:05 +0200 |
commit | 711138bc07284620979621340d97aecc00b9f520 (patch) | |
tree | 07fb7d080148b08dc644c21d01164230eba70281 /src | |
parent | Some tests already (diff) | |
download | 42-minishell-711138bc07284620979621340d97aecc00b9f520.tar.gz 42-minishell-711138bc07284620979621340d97aecc00b9f520.tar.bz2 42-minishell-711138bc07284620979621340d97aecc00b9f520.tar.xz 42-minishell-711138bc07284620979621340d97aecc00b9f520.tar.zst 42-minishell-711138bc07284620979621340d97aecc00b9f520.zip |
In progress, .gitignore update
Diffstat (limited to 'src')
-rw-r--r-- | src/b_sqb_file.c | 14 | ||||
-rw-r--r-- | src/s_init.c | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/b_sqb_file.c b/src/b_sqb_file.c index b69f160..c371d50 100644 --- a/src/b_sqb_file.c +++ b/src/b_sqb_file.c @@ -12,14 +12,15 @@ #include <sys/stat.h> #include <libft.h> +#include <stdint.h> #include <fcntl.h> #include <unistd.h> -#include <stdint.h> #include "d_define.h" static t_bool b_file_tests_one(uint8_t id, + const char path[], struct stat *st) { if (id == FT_ID_SQB_B && S_ISBLK(st->st_mode) == 1) @@ -35,6 +36,10 @@ static t_bool return (TRUE); else if (id == FT_ID_SQB_P && S_ISFIFO(st->st_mode) == 1) return (TRUE); + else if (id == FT_ID_SQB_R && access(path, R_OK) == 0) + return (TRUE); + else if (id == FT_ID_SQB_S && st->st_size != 0) + return (TRUE); return (FALSE); } @@ -52,9 +57,12 @@ uint8_t close(fd); return (0); } - fstat(fd, &st); close(fd); - if (b_file_tests_one(id, &st) == TRUE) + if (id == FT_ID_SQB_H || id == FT_ID_SQB_L_MAJ) + lstat(argv[1], &st); + else + stat(argv[1], &st); + if (b_file_tests_one(id, argv[1], &st) == TRUE) return (0); return (1); } diff --git a/src/s_init.c b/src/s_init.c index 2722c4b..7353ed8 100644 --- a/src/s_init.c +++ b/src/s_init.c @@ -36,8 +36,8 @@ static void ft_memcpy(msh->sqb_ref[FT_ID_SQB_F], FT_SQB_F, ft_strlen(FT_SQB_F) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_H], FT_SQB_H, ft_strlen(FT_SQB_H) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_N], FT_SQB_N, ft_strlen(FT_SQB_N) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_R], FT_SQB_P, ft_strlen(FT_SQB_R) + 1); - ft_memcpy(msh->sqb_ref[FT_ID_SQB_P], FT_SQB_R, ft_strlen(FT_SQB_P) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_P], FT_SQB_P, ft_strlen(FT_SQB_P) + 1); + ft_memcpy(msh->sqb_ref[FT_ID_SQB_R], FT_SQB_R, ft_strlen(FT_SQB_R) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_S], FT_SQB_S, ft_strlen(FT_SQB_S) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_W], FT_SQB_W, ft_strlen(FT_SQB_W) + 1); ft_memcpy(msh->sqb_ref[FT_ID_SQB_X], FT_SQB_X, ft_strlen(FT_SQB_X) + 1); |