From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- myfind/simple_stat/Makefile | 15 +++++++++++++++ myfind/simple_stat/simple_stat.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 myfind/simple_stat/Makefile create mode 100644 myfind/simple_stat/simple_stat.c (limited to 'myfind/simple_stat') diff --git a/myfind/simple_stat/Makefile b/myfind/simple_stat/Makefile new file mode 100644 index 0000000..f38f031 --- /dev/null +++ b/myfind/simple_stat/Makefile @@ -0,0 +1,15 @@ +CC = gcc +CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla + +SRC = simple_stat.c +OBJ = $(SRC:.c=.o) + +all: $(OBJ) + $(CC) -o simple_stat $(OBJ) + +$(OBJ): $(SRC) + +.PHONY: clean + +clean : + $(RM) $(OBJ) simple_stat diff --git a/myfind/simple_stat/simple_stat.c b/myfind/simple_stat/simple_stat.c new file mode 100644 index 0000000..27065b6 --- /dev/null +++ b/myfind/simple_stat/simple_stat.c @@ -0,0 +1,31 @@ +#include +#include + +int main(int argc, char **argv) +{ + if (argc == 1) + return 0; + + struct stat s; + + for (int i = 1; i < argc; i++) + { + if (stat(argv[i], &s) != 0) + return 1; + printf("st_dev=%ld\n", s.st_dev); + printf("st_ino=%ld\n", s.st_ino); + printf("st_mode=%07o\n", s.st_mode); + printf("st_nlink=%ld\n", s.st_nlink); + printf("st_uid=%d\n", s.st_uid); + printf("st_gid=%d\n", s.st_gid); + printf("st_rdev=%ld\n", s.st_rdev); + printf("st_size=%ld\n", s.st_size); + printf("st_atime=%ld\n", s.st_atime); + printf("st_mtime=%ld\n", s.st_mtime); + printf("st_ctime=%ld\n", s.st_ctime); + printf("st_blksize=%ld\n", s.st_blksize); + printf("st_blocks=%ld\n", s.st_blocks); + } + + return 0; +} -- cgit v1.2.3