summaryrefslogtreecommitdiffstats
path: root/src/b_sqb_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/b_sqb_file.c')
-rw-r--r--src/b_sqb_file.c14
1 files changed, 11 insertions, 3 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);
}