home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / qb / arcread.lzh / ARCREAD.BAS
BASIC Source File  |  1988-02-17  |  5KB  |  109 lines

  1. '*****************************************************************************
  2. '*                                                                           *
  3. '*                                                                           *
  4. '*                           A R C R E A D . B A S                           *
  5. '*                                                                           *
  6. '*      An example of how to access information stored in .ARC Files         *
  7. '*      Using Microsoft QuickBASIC 4.0                                       *
  8. '*                                                                           *
  9. '*                                                                           *
  10. '*                                    by                                     *
  11. '*                                                                           *
  12. '*                                 Dave Evers                                *
  13. '*                             2500 Larch Rd. #58                            *
  14. '*                             Quincy, IL   62301                            *
  15. '*                                                                           *
  16. '*                                                                           *
  17. '*                                                                           *
  18. '*                                                                           *
  19. '*****************************************************************************
  20.  
  21. 'First define a user defined type (here called ARCHDR) to define the structure
  22. 'of the archive header.  The header of .ARC files is standard, as follows:
  23. '
  24. 'Byte (within header)       Values                         Meaning
  25. '---------------------------------------------------------------------------
  26. '         1                   1Ah               Archive Header Flag
  27. '         2                   0-9               Type of storage used
  28. '
  29. '                                                 0 -
  30. '                                                 1 - Uncompressed
  31. '                                                 2 - Stored
  32. '                                                 3 - Packed
  33. '                                                 4 - Crunched
  34. '                                                 5 -
  35. '                                                 6 -
  36. '                                                 7 -
  37. '                                                 8 -
  38. '                                                 9 -
  39. '
  40. '         3-15                ---                ASCIIZ Filename
  41. '
  42. '         16-19               ---                Size of file in archive;
  43. '                                                in Long Integer format
  44. '
  45. '         20-21               ---                Date stamp of archived file;
  46. '                                                in DOS format
  47. '
  48. '         22-23               ---                Time Stamp of archived file;
  49. '                                                in DOS format
  50. '
  51. '         24-25               ---                CRC-16 of uncompressed file
  52. '
  53. '         26-29               ---                Original uncompressed file
  54. '                                                size in DOS format
  55. '
  56. '
  57. '                                                Note: Storage Type 1 files
  58. '                                                are not compressed, so this
  59. '                                                number is left off those
  60. '                                                headers; making the header
  61. '                                                only 25 bytes long.  File
  62. '                                                size can be determined by
  63. '                                                bytes 16-19.
  64.  
  65.  
  66.                 TYPE archdr
  67.  
  68.                         flag AS STRING * 1       :'String is used since QB 4.0
  69.                         stortype AS STRING * 1   :'has no BYTE variable type.
  70.                         filename AS STRING * 13
  71.                         arcsize AS LONG
  72.                         date AS INTEGER
  73.                         time AS INTEGER
  74.                         crc AS INTEGER
  75.                         fullsize AS LONG
  76.                
  77.                 END TYPE
  78.  
  79.                 CLS
  80.                 DIM arcrec as archdr
  81.                 defint a-z
  82.  
  83. arcsub:         
  84.                 OPEN [arcname$] FOR BINARY AS #1   :'replace [ARCNAME$] with name
  85.                 filepos! = 1                       :' of archive file
  86.                 WHILE NOT EOF(1)
  87.  
  88.                         GET #1, , arcrec
  89.  
  90.                         IF arcrec.stortype = CHR$(0) THEN GOTO endread
  91.                         IF arcrec.stortype = CHR$(1) then hdrsize%=25 else hdrsize%=29
  92. '
  93. '
  94. ' The body of your program to process the files in the archive would go here
  95. '
  96. '
  97. '
  98.                         filepos! = filepos! + hdrsize%  :'skip over header
  99.  
  100.                         filepos! = filepos! + arcrec.arcsize :'using size of
  101.                                                              :'archived file,
  102.                                                              :'skip to next
  103.                                                              :'header
  104.                         SEEK #1, (filepos)
  105.  
  106. another:        WEND
  107.  
  108. endread:        close
  109.