home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / disk / cdrom / mkisofs / unix / teststat.c < prev    next >
C/C++ Source or Header  |  1994-05-29  |  702b  |  34 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "unixlib.h"
  4.  
  5. void main (int argc, char *argv[])
  6. {
  7.   struct stat s;
  8.  
  9.   if (argc <= 1)
  10.     exit (0);
  11.  
  12.   remove_dot_files (argv[1]);
  13.         
  14.   if (stat (argv[1], &s) == -1) {
  15.     fprintf (stderr, "cannot stat '%s'\n", argv[1]);
  16.     exit (1);
  17.   }
  18.   
  19.   printf ("stat:\n");
  20.   printf ("  size = %d bytes\n", s.st_size);
  21.   printf ("  time = %s\n", asctime (gmtime (&s.st_atime)));
  22.   printf ("  is a %s\n", S_ISDIR(s.st_mode) ? "directory" : "file");
  23.   printf ("  permissions: ");
  24.   if (s.st_mode & S_IRUSR)
  25.     printf ("read ");
  26.   if (s.st_mode & S_IWUSR)
  27.     printf ("write ");
  28.   if (s.st_mode & S_IXUSR)
  29.     printf ("execute ");
  30.   putchar ('\n');
  31.  
  32.   exit (0);
  33. }
  34.