get_perms.c 354 B

123456789101112131415161718
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <grass/config.h>
  4. #include "access.h"
  5. int get_perms(char *path, int *perms, int *group, int *other)
  6. {
  7. struct stat buf;
  8. if (stat(path, &buf) != 0)
  9. return -1;
  10. *perms = buf.st_mode;
  11. *group = (*perms & GROUP_PERMS) ? 1 : 0;
  12. *other = (*perms & OTHER_PERMS) ? 1 : 0;
  13. return 0;
  14. }