BBS: Inland Empire Archive Date: 01-01-93 (16:35) Number: 400 From: ROBERT CHURCH Refer#: NONE To: JOEL MASLAK Recvd: NO Subj: Telling Archives Aparty Conf: (2) Quik_Bas
Joel Maslak entered the following ASCII codes for the viewing pleasure of All: JM> I am writing a program that unarchives *ALL* archives, JM> regardless of the type. To do this, I am going to make calls JM> to the various dearchiving programs, but first I need to be JM> able to tell what archive is what archive... Example: How JM> do you know it is a Zip or Arc (regardless of ext, as I am JM> writing this as an accessory for my mailtosser)? Here you go: DECLARE FUNCTION GetArchive$ (FileName$) '$DYNAMIC REM $STATIC DEFINT A-Z FUNCTION GetArchive$ (FileName$) 'Returns the DOS command needed to un-archive the passed FileName$ 'The archiver information is from the COMPRESS.CFG included in 'Scott Dudley's SquishMail message base utility. Thanks Scott! Free = FREEFILE OPEN FileName$ FOR BINARY AS #Free DIM Ident AS STRING * 5 'We'll need the first five bytes of the file GET #Free, , Ident 'GET the first five bytes IF LEFT$(Ident, 1) = CHR$(26) THEN 'We know it's an ARC if the first 'byte is an EOF. GetArchive$ = "arce " 'return the command to extract the ARC ELSEIF LEFT$(Ident, 4) = "PK" + CHR$(3) + CHR$(4) THEN 'we know it's a zip if the first three bytes GetArchive$ = "PKUNZIP " 'are "PK^C^D". ELSEIF RIGHT$(Ident, 3) = "-lh" THEN 'If the 3 bytes at offset 2 GetArchive$ = "LHA E " 'are "-lh" then we know it's an LHA. ELSEIF LEFT$(Ident, 2) = CHR$(96) + CHR$(234) THEN 'If the first 2 bytes of the file GetArchive$ = "ARJ E " 'are CHR$(96) and CHR$(234), it`s an ARJ. ELSE GetArchive$ = "" 'unknow archive type END IF CLOSE END FUNCTION SUB Unarchive (FileName AS STRING) 'un-archives a .QWK file UnpackProg$ = GetArchive$(FileName) SHELL UnpackProg$ + FileName END SUB [-= Rob =-] Internet: churchr@hilhi.rain.com --- timEd/B6 * Origin: -= The Floating Point =- Hillsboro, Oregon, USA, Earth (1:105/330.3)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET