home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 002 / frecmp10.zip / FREECOMP.C < prev    next >
Text File  |  1994-11-25  |  5KB  |  102 lines

  1. /* F R E E C O M P  1.0
  2.     A Freeware Compression Utility
  3.     Written By Tim Russell
  4.     ---
  5.     FreeComp gets info about a program and creates a batch file that you run
  6.     instead of the normal executable. It will decompress a compressed file if 
  7.     it exists, run the program, update the compressed file, and delete all the 
  8.     files except the compressed file.
  9.         Advantages to FreeComp over similar programs:
  10.          No annoying delays or registration messages
  11.          Makes its own batch files, so there is no shell program to run (and
  12.           consequently, no overhead memory!)
  13.          Totally customizable - if you don't like the batch file the way it is,
  14.           or you want to add something, it's up to you!
  15.          It's FREE!
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <conio.h>
  21.  
  22. int main(void)
  23. {
  24.         // Declare variables
  25.     char CompFileDir[60]="\0", CompFileName[12]="\0", DecompUtilDir[60]="\0"; 
  26.     char DecompUtilName[12]="\0", DecompUtilParms[40]="\0", ProgDrv[2]="\0";
  27.     char ProgDir[60]="\0", ProgExe[60]="\0", ProgParms[40]="\0";
  28.     char CompUtilDir[60]="\0", CompUtilName[12]="\0", CompUtilParms[40]="\0";
  29.     char BatFilePath[80]="\0";
  30.     FILE *batch;      
  31.  
  32.         // Clears screen
  33.     clrscr();
  34.         // Ask for compressed file directory
  35.     printf("\nWhat is the directory that the compressed file should be stored in?\n Example:  D:\\ZIPS\\\n   ");
  36.     gets(CompFileDir);
  37.         // Ask what the name of the compressed file is
  38.     printf("\nWhat is the name of the compressed file?\n Example:  MONEY.ZIP\n   ");
  39.     gets(CompFileName);
  40.         // Ask where the decompression utility is stored
  41.     printf("\nWhere is the decompression utility stored?\n Example:  D:\\UTILS\\\n   ");
  42.     gets(DecompUtilDir);
  43.         // Ask what the name of the decompression utility is
  44.     printf("\nWhat is the name of the decompression utility?\n Example:  PKUNZIP.EXE\n   ");
  45.     gets(DecompUtilName);
  46.         // Ask what parameters the decompression utility takes
  47.     printf("\nWhat parameters does the decompression utility take?\n Example:  -d -o\n   ");
  48.     gets(DecompUtilParms);
  49.         // Ask where program is stored
  50.     printf("\nWhat drive is the program on?\n Example: D:\n   ");
  51.     gets(ProgDrv);
  52.     printf("\nWhat directory is the program in?\n Example:  MONEY3\n   ");
  53.     gets(ProgDir);
  54.         // Ask for name of the program executable
  55.     printf("\nWhat is the name of the program executable?\n Example:  MONEY3.EXE\n   ");
  56.     gets(ProgExe);
  57.         // Ask for program parameters
  58.     printf("\nWhat are the program's parameters?\n Example:  /H:%1 /N:1 /F:\"%2\"\n   ");
  59.     gets(ProgParms);
  60.         // Ask for compression utility directory      
  61.     printf("\nWhere is the compression utility stored?\n Example:  D:\\UTILS\\\n   ");
  62.     gets(CompUtilDir);   
  63.         // Ask what the name of the compression utility is
  64.     printf("\nWhat is the name of the compression utility?\n Example:  PKZIP.EXE\n   ");
  65.     gets(CompUtilName);
  66.         // Ask what parameters the compression utility takes
  67.     printf("\nWhat parameters does the compression utility take?\n Example:  -P -r -ex\n   ");
  68.     gets(CompUtilParms);
  69.         // Ask where batch file should be stored
  70.     printf("\nWhere should the batch file be stored?\n Example:  D:\\BATS\\MONEY.BAT\n   ");
  71.     gets(BatFilePath);
  72.         
  73.         // Open batch file for writing
  74.     batch = fopen(BatFilePath, "w");
  75.         // Start writing lines to batch file
  76.     fprintf(batch, "@echo off\n");
  77.     fprintf(batch, "c:\n");
  78.     fprintf(batch, "md\\$$temp$$\n");
  79.     fprintf(batch, "echo Now checking for compressed file, and decompressing if it exists.\n");
  80.     fprintf(batch, "if exist %s%s %s%s %s %s%s %s\\%s\n", CompFileDir, CompFileName, DecompUtilDir, DecompUtilName, DecompUtilParms, CompFileDir, CompFileName, ProgDrv, ProgDir);
  81.     fprintf(batch, "echo Changing to the program's drive.\n");
  82.     fprintf(batch, "%s\n", ProgDrv);
  83.     fprintf(batch, "echo Changing to the program's directory.\n");
  84.     fprintf(batch, "cd\\%s\n", ProgDir);
  85.     fprintf(batch, "echo Running program with input parameters.\n");
  86.     fprintf(batch, "%s %s\n", ProgExe, ProgParms);
  87.     fprintf(batch, "echo Recompressing files.\n");
  88.     fprintf(batch, "%s%s %s %s%s *.*\n", CompUtilDir, CompUtilName, CompUtilParms, CompFileDir, CompFileName);
  89.     fprintf(batch, "if exist %s\\%s\\%s move %s\\%s\\%s C:\\$$temp$$\n", ProgDrv, ProgDir, CompFileName, ProgDrv, ProgDir, CompFileName);
  90.     fprintf(batch, "echo Deleting old files.\n");    
  91.     fprintf(batch, "del %s\\%s\\*.*\n", ProgDrv, ProgDir);
  92.     fprintf(batch, "if exist c:\\$$temp$$\\%s move c:\\$$temp$$\\%s %s\\%s\n", CompFileName, CompFileName, ProgDrv, ProgDir);
  93.     fprintf(batch, "c:\n");
  94.     fprintf(batch, "cd\\\n");
  95.     fprintf(batch, "rmdir $$temp$$\n");
  96.     fprintf(batch, "echo Done!!!\n");
  97.     fclose(batch);
  98.  
  99.         // Return errorlevel 0
  100.     return(0);  
  101. }
  102.