home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / pbc22b.zip / ARCVIEW.BAS next >
BASIC Source File  |  1993-01-11  |  4KB  |  126 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |       PBClone  Copyright (c) 1990-1993  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   +----------------------------------------------------------------------+
  6.  
  7. ' This is another simple demo of the PBClone routines.  It allows you to
  8. ' view the files in an archive (.ARC, .ARJ, .LZH, .PAK, .ZIP, or .ZOO).
  9.  
  10. ' Syntax:
  11. '   ARCVIEW arcname[.ext] [/V]
  12.  
  13. ' The file extension for the archive is optional, although you may want to
  14. ' specify it if there is a possibility that you have two archives of the
  15. ' same name but different extensions (e.g., FOO.ARJ and FOO.ZIP).  The /V
  16. ' option allows you to specify a full listing-- without it, you will get
  17. ' a "wide format" display containing just the file names in the archive.
  18.  
  19. ' Typically, this would be converted to an .EXE file using these steps:
  20. '    BC ARCVIEW/O;
  21. '    LINK ARCVIEW/EX,,NUL,PBCLONE;
  22.  
  23.    DECLARE SUB CloseA ()
  24.    DECLARE SUB DateN2S (MonthNr%, DayNr%, YearNr%, DateSt$)
  25.    DECLARE SUB FindFirstA (Archive$, FileName$, ErrCode%)
  26.    DECLARE SUB FindNextA (ErrCode%)
  27.    DECLARE SUB GetCRCAL (CRC32&)
  28.    DECLARE SUB GetDateA (MonthNr%, DayNr%, YearNr%)
  29.    DECLARE SUB GetNameA (FileName$, FileNameLen%)
  30.    DECLARE SUB GetSizeAL (OriginalSize&, CurrentSize&)
  31.    DECLARE SUB GetTimeA (HourNr%, MinuteNr%, SecondNr%)
  32.    DECLARE SUB TimeN2S (HourNr%, MinuteNr%, SecondNr%, TimeSt$)
  33.  
  34.    DECLARE SUB PrintComma (Number&, FieldLen%)
  35.  
  36.    DEFINT A-Z
  37.  
  38.    Cmd$ = LTRIM$(RTRIM$(UCASE$(COMMAND$)))
  39.    IF LEN(Cmd$) = 0 OR INSTR(Cmd$, "/?") > 0 THEN
  40.       PRINT "ARCVIEW: View Archive Demo for PBClone by Thomas G. Hanlin III"
  41.       PRINT
  42.       PRINT "Syntax:"
  43.       PRINT "  ARCVIEW arcname[.ext] [/V]
  44.       PRINT
  45.       PRINT "Use /V for a full listing, as opposed to just a list of the files contained"
  46.       PRINT "in the archive.  ARCVIEW currently supports ARC, ARJ, LZH, PAK, ZIP, and ZOO."
  47.       END
  48.    END IF
  49.    tmp = INSTR(Cmd$, "/V")
  50.    IF tmp THEN
  51.       FullView = -1
  52.       Cmd$ = LTRIM$(RTRIM$(LEFT$(Cmd$, tmp - 1) + MID$(Cmd$, tmp + 2)))
  53.    END IF
  54.    IF LEN(Cmd$) THEN
  55.       Arc$ = Cmd$
  56.    ELSE
  57.       PRINT "Please specify the name of an archive."
  58.       END
  59.    END IF
  60.  
  61.    FindFirstA Arc$, "*.*", ErrCode
  62.    IF ErrCode THEN
  63.       PRINT "Unable to open archive "; CHR$(34); Arc$; CHR$(34)
  64.       END
  65.    END IF
  66.  
  67.    IF FullView THEN
  68.       PRINT "Filename              Date       Time    CRC        Curr. Size    Orig. Size"
  69.       PRINT "-------------------   --------   -----   --------   -----------   -----------"
  70.    END IF
  71.  
  72.    FileName$ = SPACE$(80)
  73.    DO
  74.       GetNameA FileName$, FLen
  75.       IF FullView THEN
  76.          IF FLen > 22 THEN
  77.             F$ = "..." + RIGHT$(LEFT$(FileName$, FLen), 19)
  78.             FLen = 22
  79.          ELSE
  80.             F$ = LEFT$(FileName$, FLen)
  81.          END IF
  82.          PRINT F$; SPACE$(22 - FLen);
  83.          GetDateA MonthNr, DayNr, YearNr
  84.          DateSt$ = "xx/xx/xx"
  85.          DateN2S MonthNr, DayNr, YearNr, DateSt$
  86.          PRINT DateSt$; "   ";
  87.          GetTimeA HourNr, MinuteNr, SecondNr
  88.          TimeSt$ = "xx:xx"
  89.          TimeN2S HourNr, MinuteNr, SecondNr, TimeSt$
  90.          PRINT TimeSt$; "   ";
  91.          GetCRCAL CRC32&
  92.          HexCRC$ = RIGHT$("00000000" + HEX$(CRC32&), 8)
  93.          PRINT HexCRC$;
  94.          GetSizeAL OriginalSize&, CurrentSize&
  95.          PrintComma CurrentSize&, 14
  96.          PrintComma OriginalSize&, 14
  97.          PRINT
  98.       ELSE
  99.          IF FLen > 15 THEN
  100.             F$ = "..." + RIGHT$(LEFT$(FileName$, FLen), 12)
  101.             FLen = 15
  102.          ELSE
  103.             F$ = LEFT$(FileName$, FLen)
  104.          END IF
  105.          PRINT F$; SPACE$(16 - FLen);
  106.       END IF
  107.       FindNextA ErrCode
  108.    LOOP UNTIL ErrCode
  109.  
  110.    CloseA
  111.  
  112. SUB PrintComma (Number&, FieldLen)
  113.    N$ = LTRIM$(STR$(Number&))
  114.    R$ = ""
  115.    DO WHILE LEN(N$) > 3
  116.       R$ = RIGHT$(N$, 3) + "," + R$
  117.       N$ = LEFT$(N$, LEN(N$) - 3)
  118.    LOOP
  119.    IF LEN(N$) THEN R$ = N$ + "," + R$
  120.    IF RIGHT$(R$, 1) = "," THEN R$ = LEFT$(R$, LEN(R$) - 1)
  121.    IF LEN(R$) < FieldLen THEN
  122.       R$ = SPACE$(FieldLen - LEN(R$)) + R$
  123.    END IF
  124.    PRINT R$;
  125. END SUB
  126.