home *** CD-ROM | disk | FTP | other *** search
/ Carousel / CAROUSEL.cdr / mactosh / utilfil / resdes.sit / rezdest.c < prev    next >
C/C++ Source or Header  |  1989-05-04  |  1KB  |  54 lines

  1. /*
  2.  * Rezdest: Delete the resource fork of text files.
  3.  * An MPW Tool by
  4.  * Earle R. Horton Thursday, April 27, 1989
  5.  *
  6.  * MPW v. 2.0.2 compatibility alert:  Pascal strings used to call
  7.  * Toolbox!!!!
  8.  */
  9. #include <stdio.h>
  10. #include <files.h>
  11. #include <CursorCtl.h>
  12. main(argc, argv)
  13. int argc;
  14. char **argv;
  15. {
  16.     int i;
  17.     int refnum;
  18.     FInfo   info;
  19.     OSErr   err;
  20.     int quiet = 0;
  21.     InitCursorCtl(nil);
  22.     for(i=1;i<argc;i++){
  23.         if(argv[i][0] == '-'){
  24.             switch(argv[i][1]){
  25.                 case 'q':
  26.                 case 'Q':
  27.                     quiet = 1;
  28.                     break;
  29.                 default:
  30.                     fprintf(stderr,"Usage: %s [-q] files.\r",argv[0]);
  31.                     exit();
  32.             }
  33.         }else{
  34.             SpinCursor (32);
  35.             c2pstr(argv[i]);
  36.             GetFInfo(argv[i],0,&info);
  37.             if(info.fdType != 'TEXT'){
  38.                 if(quiet == 0){
  39.                     p2cstr(argv[i]);
  40.                     fprintf(stderr,"\"%s\" is not a 'TEXT' file!\r",argv[i]);
  41.             }
  42.             }else{
  43.                 if(!(err = OpenRF(argv[i],0,&refnum))){
  44.                     SetEOF(refnum,0L);
  45.                     FSClose(refnum);
  46.                 }else{
  47.                     p2cstr(argv[i]);
  48.                     fprintf(stderr,"Open problem on %s\r",argv[i]);
  49.                 }
  50.             }
  51.         }
  52.     }
  53. }
  54.