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 >
Wrap
BASIC Source File
|
1992-12-14
|
6KB
|
173 lines
' ETUNZIP.EXE
' (C) Copyright 1992-1993 EllTech Development, Inc.
' All rights reserved
' =======================================================================
REM $INCLUDE: 'compress.bi'
REM $INCLUDE: 'compres2.bi'
REM $INCLUDE: 'etdecasm.bi'
Version$ = "1.00"
Cmd$ = UCASE$(COMMAND$)
PRINT
PRINT "ETUNZIP v"; Version$
PRINT "Data DeCompression Utility"
PRINT "(C) Copyright 1992-1993 EllTech Development, Inc."
PRINT "All rights reserved."
PRINT
PRINT "This utility demostrates some of the capabilities of EllTech's"
PRINT CHR$(34); "Compression Plus"; CHR$(34); " data compression library for QuickBASIC,"
PRINT "PDS, and VBDOS programmers. For more information, contact"
PRINT "EllTech Development, Inc. at (404) 928-8960 or on CIS at 76220,2575."
PRINT
IF LEN(Cmd$) = 0 THEN 'If no command line arguments were
GOTO ShowHelp ' passed in, remind the user the
END IF ' program syntax.
DIM Param$(1 TO 20, 0 TO 1)
Sep$ = " "
CALL EtParseCmdLine(Cmd$, Sep$, Param$(), Found%) 'Otherwise, parse out the command line
IF Found% < 1 THEN 'zip file name is required
GOTO ShowHelp 'remedial reading :-)
END IF
Pcnt% = 0
SpecCnt% = 0
REDIM Spec$(1 TO 10)
FOR I% = 1 TO Found%
SELECT CASE LEFT$(Param$(I%, 0), 1)
CASE "-", "/": 'this is a switch
Switch$ = Switch$ + Param$(I%, 0)
CASE ELSE
Pcnt% = Pcnt% + 1
SELECT CASE Pcnt%
CASE 1 'first non-switch is arc file name
ArcFile$ = Param$(I%, 0)
CASE 2
Target$ = Param$(I%, 0)
CASE IS >= 3 'other non-switch params are file specs
IF SpecCnt% < UBOUND(Spec$) THEN
SpecCnt% = SpecCnt% + 1
Spec$(SpecCnt%) = Param$(I%, 0)
END IF
CASE ELSE
END SELECT
END SELECT
NEXT
IF INSTR(ArcFile$, ".") = 0 THEN 'default extension
ArcFile$ = ArcFile$ + ".zip"
END IF
IF NOT EtFileExist%(ArcFile$) THEN
PRINT "Zip File Not Found: "; ArcFile$
GOTO AllDone
END IF
'-----check target
IF LEN(Target$) THEN
IF INSTR(Switch$, "V") > 0 THEN
SpecCnt% = SpecCnt% + 1 'No target on view
Spec$(SpecCnt%) = Target$
ELSE
IF RIGHT$(Target$, 1) <> ":" AND RIGHT$(Target$, 1) <> "\" THEN
Target$ = Target$ + "\"
END IF
Status% = EtFileOpen%(Target$ + "etcmprs.$$$", 0, Handle%)
IF Status% THEN
PRINT "Invalid Target: "; Target$
GOTO ShowHelp
END IF
EtFileClose Handle%
Temp% = EtFileDelete%(Target$ + "etcmprs.$$$")
END IF
END IF
IF SpecCnt% = 0 THEN
SpecCnt% = 1
Spec$(1) = "*.*" 'default spec
END IF
IF INSTR(Switch$, "V") THEN
Status% = EtViewZip%(ArcFile$, Spec$())
MatchCnt% = 1
ELSE
MatchCnt% = 0
Status% = EtZipOpen(ArcFile$, Mode%, Handle%)
IF Status% THEN
PRINT "Error"; Status%; "opening file "; ArcFile$; "."
END
END IF
FOR I% = 1 TO SpecCnt%
'Process each spec, one at a time.
IF LEN(Spec$(I%)) THEN
Status% = EtUnZip%(Handle%, Target$, Spec$(I%), Switch$)
END IF
IF Status% = -7 THEN 'if no files were found for this spec
Status% = 0 'we want to try all the file specs before
ELSE 'we report an error
MatchCnt% = MatchCnt% + 1
END IF
IF Status% THEN
EXIT FOR
END IF
NEXT
END IF
IF Status% THEN
SELECT CASE Status%
CASE -1
ArcType% = EtArcType%(Handle%, Status%)
SELECT CASE ArcType%
CASE 2:
PRINT "Cannot Decompress ARJ files ... Use -v to view"
CASE 3:
PRINT "Cannot Decompress LZH files ... Use -v to view"
CASE ELSE
PRINT "Unrecognized File Format: "; ArcFile$
END SELECT
CASE -2
PRINT "Error in Zip: "; ArcFile$
CASE -3
PRINT "Unknown Compression Method"
CASE -4
PRINT "Encrypted File"
CASE -5
PRINT "CRC Error"
CASE -6
PRINT "Zip File Not Found"
CASE -8
PRINT "Errors Encountered"
CASE IS > 0
PRINT "DOS Error : "; Status%
CASE ELSE
PRINT "Error Status: "; Status%
END SELECT
ELSEIF MatchCnt% = 0 THEN
PRINT "Nothing To Do"
ELSE
PRINT "Unzip Successful"
END IF
EtZipClose Handle%
GOTO AllDone
ShowHelp:
PRINT
PRINT "Syntax: EtUnZip [Switches] ArchiveFile [TargetPath] [FileSpec [FileSpec...]]"
PRINT "ie: EtUnZip -d Stuff.Zip c:\stuff *.asm -d"
PRINT
PRINT "Valid Switches: -d Create paths if stored with filename"
PRINT " -o Overwrite without prompting"
PRINT " -v View Zip Directory"
AllDone:
END