file.c 382 B

12345678910111213141516171819
  1. #include "__virtualmath.h"
  2. /**
  3. *
  4. * @param dir 文件地址
  5. * @return 0-错误, 1-普通文件, 2-目录
  6. */
  7. int checkFile(char *dir){
  8. struct stat my_stat;
  9. int status = stat(dir, &my_stat);
  10. if (status != 0)
  11. return 0;
  12. else if (S_ISREG(my_stat.st_mode))
  13. return 1;
  14. else if (S_ISDIR(my_stat.st_mode))
  15. return 2;
  16. else
  17. return 3;
  18. }