home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / c / compdem.zip / ETUNZIP.BAS < prev    next >
BASIC Source File  |  1992-12-14  |  6KB  |  173 lines

  1.     '   ETUNZIP.EXE
  2.     '   (C) Copyright 1992-1993 EllTech Development, Inc.
  3.     '   All rights reserved
  4.  
  5.     '   =======================================================================
  6.     REM $INCLUDE: 'compress.bi'
  7.     REM $INCLUDE: 'compres2.bi'
  8.     REM $INCLUDE: 'etdecasm.bi'
  9.  
  10.     Version$ = "1.00"
  11.     Cmd$ = UCASE$(COMMAND$)
  12.  
  13.     PRINT
  14.     PRINT "ETUNZIP v"; Version$
  15.     PRINT "Data DeCompression Utility"
  16.     PRINT "(C) Copyright 1992-1993 EllTech Development, Inc."
  17.     PRINT "All rights reserved."
  18.     PRINT
  19.     PRINT "This utility demostrates some of the capabilities of EllTech's"
  20.     PRINT CHR$(34); "Compression Plus"; CHR$(34); " data compression library for QuickBASIC,"
  21.     PRINT "PDS, and VBDOS programmers. For more information, contact"
  22.     PRINT "EllTech Development, Inc. at (404) 928-8960 or on CIS at 76220,2575."
  23.     PRINT
  24.  
  25.     IF LEN(Cmd$) = 0 THEN                                  'If no command line arguments were
  26.         GOTO ShowHelp                                      ' passed in, remind the user the
  27.     END IF                                                 ' program syntax.
  28.  
  29.     DIM Param$(1 TO 20, 0 TO 1)
  30.     Sep$ = " "
  31.     CALL EtParseCmdLine(Cmd$, Sep$, Param$(), Found%)      'Otherwise, parse out the command line
  32.  
  33.     IF Found% < 1 THEN                                     'zip file name is required
  34.         GOTO ShowHelp                                      'remedial reading :-)
  35.     END IF
  36.  
  37.     Pcnt% = 0
  38.     SpecCnt% = 0
  39.     REDIM Spec$(1 TO 10)
  40.     FOR I% = 1 TO Found%
  41.         SELECT CASE LEFT$(Param$(I%, 0), 1)
  42.             CASE "-", "/":                                 'this is a switch
  43.                 Switch$ = Switch$ + Param$(I%, 0)
  44.             CASE ELSE
  45.                 Pcnt% = Pcnt% + 1
  46.                 SELECT CASE Pcnt%
  47.                     CASE 1                                 'first non-switch is arc file name
  48.                         ArcFile$ = Param$(I%, 0)
  49.                     CASE 2
  50.                         Target$ = Param$(I%, 0)
  51.                     CASE IS >= 3                           'other non-switch params are file specs
  52.                         IF SpecCnt% < UBOUND(Spec$) THEN
  53.                             SpecCnt% = SpecCnt% + 1
  54.                             Spec$(SpecCnt%) = Param$(I%, 0)
  55.                         END IF
  56.                     CASE ELSE
  57.                 END SELECT
  58.         END SELECT
  59.     NEXT
  60.  
  61.     IF INSTR(ArcFile$, ".") = 0 THEN                       'default extension
  62.         ArcFile$ = ArcFile$ + ".zip"
  63.     END IF
  64.     IF NOT EtFileExist%(ArcFile$) THEN
  65.         PRINT "Zip File Not Found: "; ArcFile$
  66.         GOTO AllDone
  67.     END IF
  68.  
  69.     '-----check target
  70.     IF LEN(Target$) THEN
  71.         IF INSTR(Switch$, "V") > 0 THEN
  72.             SpecCnt% = SpecCnt% + 1                        'No target on view
  73.             Spec$(SpecCnt%) = Target$
  74.         ELSE
  75.             IF RIGHT$(Target$, 1) <> ":" AND RIGHT$(Target$, 1) <> "\" THEN
  76.                 Target$ = Target$ + "\"
  77.             END IF
  78.             Status% = EtFileOpen%(Target$ + "etcmprs.$$$", 0, Handle%)
  79.             IF Status% THEN
  80.                 PRINT "Invalid Target: "; Target$
  81.                 GOTO ShowHelp
  82.             END IF
  83.             EtFileClose Handle%
  84.             Temp% = EtFileDelete%(Target$ + "etcmprs.$$$")
  85.         END IF
  86.     END IF
  87.     
  88.     IF SpecCnt% = 0 THEN
  89.         SpecCnt% = 1
  90.         Spec$(1) = "*.*"                                   'default spec
  91.     END IF
  92.  
  93.     IF INSTR(Switch$, "V") THEN
  94.         Status% = EtViewZip%(ArcFile$, Spec$())
  95.         MatchCnt% = 1
  96.     ELSE
  97.         MatchCnt% = 0
  98.         Status% = EtZipOpen(ArcFile$, Mode%, Handle%)
  99.         IF Status% THEN
  100.             PRINT "Error"; Status%; "opening file "; ArcFile$; "."
  101.             END
  102.         END IF
  103.         FOR I% = 1 TO SpecCnt%
  104.             'Process each spec, one at a time.
  105.             IF LEN(Spec$(I%)) THEN
  106.                 Status% = EtUnZip%(Handle%, Target$, Spec$(I%), Switch$)
  107.             END IF
  108.  
  109.             IF Status% = -7 THEN            'if no files were found for this spec
  110.                 Status% = 0                 'we want to try all the file specs before
  111.             ELSE                            'we report an error
  112.                 MatchCnt% = MatchCnt% + 1
  113.             END IF
  114.  
  115.             IF Status% THEN
  116.                 EXIT FOR
  117.             END IF
  118.         NEXT
  119.     END IF
  120.  
  121.     IF Status% THEN
  122.         SELECT CASE Status%
  123.             CASE -1
  124.                 ArcType% = EtArcType%(Handle%, Status%)
  125.                 SELECT CASE ArcType%
  126.                     CASE 2:
  127.                         PRINT "Cannot Decompress ARJ files ... Use -v to view"
  128.                     CASE 3:
  129.                         PRINT "Cannot Decompress LZH files ... Use -v to view"
  130.                     CASE ELSE
  131.                         PRINT "Unrecognized File Format: "; ArcFile$
  132.                 END SELECT
  133.  
  134.             CASE -2
  135.                 PRINT "Error in Zip: "; ArcFile$
  136.             CASE -3
  137.                 PRINT "Unknown Compression Method"
  138.             CASE -4
  139.                 PRINT "Encrypted File"
  140.             CASE -5
  141.                 PRINT "CRC Error"
  142.             CASE -6
  143.                 PRINT "Zip File Not Found"
  144.             CASE -8
  145.                 PRINT "Errors Encountered"
  146.             CASE IS > 0
  147.                 PRINT "DOS Error : "; Status%
  148.             CASE ELSE
  149.                 PRINT "Error Status: "; Status%
  150.         END SELECT
  151.     ELSEIF MatchCnt% = 0 THEN
  152.         PRINT "Nothing To Do"
  153.     ELSE
  154.         PRINT "Unzip Successful"
  155.     END IF
  156.  
  157.     EtZipClose Handle%
  158.     GOTO AllDone
  159.  
  160. ShowHelp:
  161.     PRINT
  162.     PRINT "Syntax: EtUnZip [Switches] ArchiveFile [TargetPath] [FileSpec [FileSpec...]]"
  163.     PRINT "ie:     EtUnZip -d Stuff.Zip c:\stuff *.asm -d"
  164.     PRINT
  165.     PRINT "Valid Switches: -d Create paths if stored with filename"
  166.     PRINT "                -o Overwrite without prompting"
  167.     PRINT "                -v View Zip Directory"
  168.  
  169.  
  170. AllDone:
  171.     END
  172.  
  173.