123456789101112131415161718192021222324252627 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
- #include <sys/stat.h>
- #define BOLD_GRAY "\033[1;90m"
- #define RED "\033[0;31m"
- #define WHITE "\033[0;37m"
- #define RESET "\033[0m"
- int module_01_run(const char *filename) {
- char log_msg[1024];
- struct stat st;
- if (stat(filename, &st) != 0) {
- snprintf(log_msg, sizeof(log_msg), BOLD_GRAY " Main: " RED "Cannot stat file: %s" RESET, strerror(errno));
- printf("%s\n", log_msg);
- return 1;
- }
- int is_regular = S_ISREG(st.st_mode);
- snprintf(log_msg, sizeof(log_msg), BOLD_GRAY " Main: " WHITE "File is %s" RESET, is_regular ? "regular file" : "not a regular file");
- printf("%s\n", log_msg);
- return 0;
- }
|