1. #include <unistd.h>
    2. #include <stdio.h>
    3. #include <stdbool.h>
    4. bool fileExists(const char *pathname) {
    5. return access(pathname, F_OK) == 0;
    6. }
    7. int main(int argc, char **argv) {
    8. printf("/data exists: %d\n", fileExists("/data"));
    9. printf("/test exists: %d\n", fileExists("/test"));
    10. printf("/data/redis-master/Makefile exists: %d\n", fileExists("/data/redis-master/Makefile"));
    11. return 0;
    12. }