home *** CD-ROM | disk | FTP | other *** search
/ BUG 6 / BUGCD1997_09.BIN / UTIL / ADDZIP / ADDZIP.EXE / TEST16 / TEST16.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-01  |  4.9 KB  |  117 lines

  1. //
  2. //  File        : test16.cpp
  3. //  Description : test the 16-bit addZIP Compression Libraries
  4. //
  5. //  Copyright ⌐ 1996 Stephen Darlington. All rights reserved.
  6. //
  7. //  You have a royalty-free right to use, modify, reproduce and
  8. //  distribute this (and any other) example file (or any modified
  9. //  version) in any way you find useful, provided that you agree
  10. //  that Stephen Darlington has no warranty obligations or liability.
  11.  
  12.  
  13. #include <windows.h>
  14. #include <io.h>
  15. #include "azip.h"
  16. #include "aunzip.h"
  17. #include "ntfy_box.h"
  18.  
  19. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  20.     char *cTitle = "Test for 16-bit addZIP Compression Library";
  21.     char cMessage[1000];
  22.     char *cArchive = "TEST16.ZIP";
  23.     char cFiles[256];
  24.     char cWinDir[256];
  25.     int iReturn;
  26.  
  27.     GetWindowsDirectory((LPSTR)cWinDir, sizeof(cWinDir));
  28.  
  29.     wsprintf(cMessage, "This is a simple test for the 16-bit addZIP Compression Libraries. \
  30. Please follow the on-screen prompts.\n\nDo you wish to proceed?");
  31.     if (MessageBox(NULL, cMessage, cTitle, MB_YESNO) != IDYES) return 0;
  32. //
  33. // STEP 1 - adding files
  34. //
  35.     wsprintf(cFiles, "%s\\*.INI", cWinDir);
  36.     wsprintf(cMessage, "Step 1: adding %s to %s.\n\nThis will use the default compression \
  37. (COMPRESSION_NORMAL), save full path information (SAVE_ABSOLUTE_PATH) and query the user \
  38. if the file already exists in the archive (OVERWRITE_QUERY).\n\nDo you wish to proceed?", cFiles, cArchive);
  39.     if (MessageBox(NULL, cMessage, cTitle, MB_YESNO) != IDYES) return 0;
  40.  
  41.     wsprintf(cMessage, "Compressing %s to %s ...", cFiles, cArchive);
  42.     NotifyBox(NULL, cMessage, cTitle, hInstance);
  43.     addZIP_ArchiveName(cArchive);
  44.     // the following are commented out because they are redundant when using the
  45.     // default values
  46.     //addZIP_Overwrite(OVERWRITE_QUERY);
  47.     //addZIP_SetCompressionLevel(COMPRESSION_NORMAL);
  48.     //addZIP_SaveStructure(SAVE_ABSOLUTE_PATH);
  49.     addZIP_Include(cFiles);
  50.     iReturn = addZIP();
  51.     NotifyBox(NULL, NULL, NULL, NULL);
  52.     wsprintf(cMessage, "%i files matching %s successfully compressed to %s. \
  53. You may want to examine the .ZIP archive at this point, or click OK to proceed.",
  54.     iReturn, cFiles, cArchive);
  55.     MessageBox(NULL, cMessage, cTitle, MB_OK);
  56. //
  57. // STEP 2
  58. //
  59.     wsprintf(cFiles, "%s\\*.BMP", cWinDir);
  60.     wsprintf(cMessage, "Step 2: adding %s to %s.\n\nThis will use the maximum compression \
  61. (COMPRESSION_MAXIMUM), save no path information (SAVE_FILENAME_ONLY) and query the user \
  62. if the file already exists in the archive (OVERWRITE_QUERY).\n\nDo you wish to proceed?", cFiles, cArchive);
  63.     if (MessageBox(NULL, cMessage, cTitle, MB_YESNO) != IDYES) return 0;
  64.     wsprintf(cMessage, "Compressing %s to %s ...", cFiles, cArchive);
  65.     NotifyBox(NULL, cMessage, cTitle, hInstance);
  66.     addZIP_ArchiveName(cArchive);
  67.     //addZIP_Overwrite(OVERWRITE_QUERY);
  68.     addZIP_SetCompressionLevel(COMPRESSION_MAXIMUM);
  69.     addZIP_SaveStructure(SAVE_FILENAME_ONLY);
  70.     addZIP_Include(cFiles);
  71.     iReturn = addZIP();
  72.     NotifyBox(NULL, NULL, NULL, NULL);
  73.     wsprintf(cMessage, "%i files matching %s successfully compressed to %s. \
  74. You may want to examine the .ZIP archive at this point, or click OK to proceed.",
  75.     iReturn, cFiles, cArchive);
  76.     MessageBox(NULL, cMessage, cTitle, MB_OK);
  77. //
  78. // STEP 3 - deleting files
  79. //
  80.     wsprintf(cFiles, "%s\\*.INI", cWinDir);
  81.     wsprintf(cMessage, "Step 3: deleting %s from %s.\n\nThis will remove only those files \
  82. matching %s and will ignore files that match *.INI.\n\nDo you wish to proceed?", cFiles, cArchive, cFiles);
  83.     if (MessageBox(NULL, cMessage, cTitle, MB_YESNO) != IDYES) return 0;
  84.     wsprintf(cMessage, "Deleting %s from %s ...", cFiles, cArchive);
  85.     NotifyBox(NULL, cMessage, cTitle, hInstance);
  86.     addZIP_ArchiveName(cArchive);
  87.     addZIP_Include(cFiles);
  88.     addZIP_Delete(TRUE);
  89.     iReturn = addZIP();
  90.     NotifyBox(NULL, NULL, NULL, NULL);
  91.     wsprintf(cMessage, "%i files matching %s successfully deleted from %s. \
  92. You may want to examine the .ZIP archive at this point, or click OK to proceed.",
  93.     iReturn, cFiles, cArchive);
  94.     MessageBox(NULL, cMessage, cTitle, MB_OK);
  95. //
  96. // STEP 4 - extracting files
  97. //
  98.     wsprintf(cMessage, "Step 4: extracting all files from %s.\n\nThis step will decompress all \
  99. the files from the .ZIP archive to the C:\TEMP directory (which will be created if it \
  100. does not already exist). All stored path information will be ignored.\
  101. \n\nDo you wish to proceed?", cArchive);
  102.     if (MessageBox(NULL, cMessage, cTitle, MB_YESNO) != IDYES) return 0;
  103.     wsprintf(cMessage, "Extracting *.* from %s ...", cArchive);
  104.     NotifyBox(NULL, cMessage, cTitle, hInstance);
  105.     addUNZIP_ArchiveName(cArchive);
  106.     addUNZIP_Include("*.*");
  107.     addUNZIP_ExtractTo("c:\\temp");
  108.     iReturn = addUNZIP();
  109.     NotifyBox(NULL, NULL, NULL, NULL);
  110.     wsprintf(cMessage, "%i files successfully extracted to C:\\TEMP.\n\n\
  111. This ends the test of the addZIP Compression Libraries. The archive %s will be deleted when \
  112. you click OK.", iReturn);
  113.     MessageBox(NULL, cMessage, cTitle, MB_OK);
  114.     unlink(cArchive);
  115.     return 0;
  116. }
  117.