home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / ArchiveUtils / JumpBack / Source / file_writable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  483 b   |  25 lines

  1. #import <sys/stat.h>    /* stat */
  2. #import <stdio.h>    /* fgets */
  3. #import <sys/param.h>    /* MAXPATHLEN */
  4. #import <string.h>
  5. #import <stdlib.h>    /* exit */
  6.  
  7. int main(int argc, char *argv[]) 
  8. {
  9.     char *buf;
  10.     struct    stat sbuf;
  11.  
  12.     if (argc < 2)
  13.         exit(1);
  14.     /*
  15.      * examine the file name comeing in from standard in
  16.      * non writable files
  17.      */
  18.     buf = argv[1];
  19.     if ( (stat(buf,&sbuf)== -1) || ((sbuf.st_mode & S_IWRITE)!= S_IWRITE ))
  20.     {
  21.         exit(1);
  22.     }
  23.     
  24.     exit(0);
  25. }