is_file.cpp 400 B

12345678910111213141516171819
  1. #include "is_file.h"
  2. #include <sys/stat.h>
  3. #ifdef _WIN32
  4. # ifndef S_ISREG
  5. # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  6. # endif
  7. #endif
  8. IGL_INLINE bool igl::is_file(const char * filename)
  9. {
  10. struct stat status;
  11. if(stat(filename,&status)!=0)
  12. {
  13. // path does not exist
  14. return false;
  15. }
  16. // Tests whether existing path is a regular file
  17. return S_ISREG(status.st_mode);
  18. }