home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / access.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  1.6 KB  |  74 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.1
  10. date    92.05.14.19.55.40;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @check access permissions for path
  17. n
  18. @
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/*
  27.  *  This file is part of ixemul.library for the Amiga.
  28.  *  Copyright (C) 1991, 1992  Markus M. Wild
  29.  *
  30.  *  This library is free software; you can redistribute it and/or
  31.  *  modify it under the terms of the GNU Library General Public
  32.  *  License as published by the Free Software Foundation; either
  33.  *  version 2 of the License, or (at your option) any later version.
  34.  *
  35.  *  This library is distributed in the hope that it will be useful,
  36.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  37.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  38.  *  Library General Public License for more details.
  39.  *
  40.  *  You should have received a copy of the GNU Library General Public
  41.  *  License along with this library; if not, write to the Free
  42.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  43.  *
  44.  *  $Id$
  45.  *
  46.  *  $Log$
  47.  */
  48.  
  49. #define KERNEL
  50. #include "ixemul.h"
  51.  
  52. int
  53. access(char *name, int mode)
  54. {
  55.   struct stat stb;
  56.   int res;
  57.  
  58.   res = -1;
  59.   if (syscall (SYS_stat, name, &stb) == 0)
  60.     {
  61.       /* this doesn't check, whether the volume on which this files
  62.        * lies itself permits the desired actions, on a readonly-fs
  63.        * the write-permission on the file doesn't count.. HOW should
  64.        * I get at this information?? */
  65.       res = (((stb.st_mode >> 6) & 07)&mode)==mode ? 0 : -1;
  66.       if (res) errno = EACCES;
  67.     }
  68.   else
  69.     errno = ENOENT;  
  70.  
  71.   return res;
  72. }
  73. @
  74.