home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI09.ARJ / ictari.09 / C / KILL_BAK / KILL_BAK.C next >
C/C++ Source or Header  |  1997-09-17  |  1KB  |  61 lines

  1. #include "c:\work\headers\portab.h"
  2. #include "c:\work\headers\osbind.h"
  3. #include "c:\work\headers\string.h"
  4.  
  5. int kill_count;
  6.  
  7. void kill_it(path,dta)
  8. char *path,*dta;
  9. {
  10. char file[128];
  11. kill_count++;
  12. strcpy(file,path);
  13. /* check if path is root! */
  14. if(strlen(file)>3)
  15.         strcat(file,"\\");
  16. strcat(file,dta+30);
  17. printf("%s \n",file);
  18. if(Fdelete(file)<0)
  19.         {
  20.         printf("Error deleting file: %s\nProcess will terminate on keypress...\n",file);
  21.         getch();
  22.         exit(-1);
  23.         }
  24. }
  25.  
  26. void main(argc,argv)
  27. WORD argc;
  28. char *argv[];
  29. {
  30. char path[128];
  31. char *pointer;
  32. kill_count=0;
  33. if(argc==1)
  34.         {
  35.         path[0]=Dgetdrv()+'A';
  36.         strcpy(&path[1],":\\*.bak");
  37.         }
  38. else if(argc==2)
  39.         {
  40.         if(strlen(argv[1])<=2)
  41.                 {
  42.                 path[0]=*(argv[1]);
  43.                 strcpy(&path[1],":\\*.bak");
  44.                 }
  45.         else if(strlen(argv[1])>2)
  46.                 {
  47.                 strcpy(path,argv[1]);
  48.                 pointer=strrchr(path,'\\');
  49.                 if(pointer<(path+strlen(path)-1))
  50.                         strcat(path,"\\*.bak");
  51.                 else
  52.                         strcat(path,"*.bak");
  53.                 }
  54.         }
  55. else    
  56.         return;
  57. filefind(path,kill_it);
  58. printf("%u .bak files deleted\n",kill_count);
  59. }
  60.  
  61.