home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / PBC22B.ZIP / PBC$BAS.ZIP / IDFILE.BAS < prev    next >
BASIC Source File  |  1993-01-01  |  14KB  |  298 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |        PBClone  Copyright (c) 1990-1993  Thomas G. Hanlin III        |
  4. '   |                                                                      |
  5. '   +----------------------------------------------------------------------+
  6.  
  7.    DECLARE SUB FClose1 (BYVAL FileHandle%)
  8.    DECLARE SUB FOpen1 (FileName$, BYVAL ReadWrite%, BYVAL Sharing%, FileHandle%, ErrCode%)
  9.    DECLARE SUB SFRead (BYVAL FileHandle%, St$, BytesRead%, ErrCode%)
  10.  
  11. SUB IdentifyFile (FileName$, Description$, DescriptionLen%)
  12.  
  13.    File$ = UCASE$(FileName$)
  14.    IF RIGHT$(File$, 1) = CHR$(0) THEN
  15.       File$ = LEFT$(File$, LEN(File$) - 1)
  16.    END IF
  17.  
  18.    Tmp% = INSTR(File$, ".")
  19.    IF Tmp% THEN
  20.       Extension$ = MID$(File$, Tmp% + 1)
  21.    ELSE
  22.       Extension$ = ""
  23.    END IF
  24.  
  25.    D$ = ""
  26.    DetailedCheck% = 0
  27.  
  28.    SELECT CASE Extension$
  29.       CASE "$$$": D$ = "temporary pipe file"
  30.       CASE "@@@": D$ = "backup ID file"
  31.       CASE "$$$": D$ = "temporary or backup file"
  32.       CASE "ACT": D$ = "program source code (Actor) or comm account data (BITCOM)"
  33.       CASE "AIO": D$ = "APL file transfer format file"
  34.       CASE "AMG": D$ = "system image file (Actor)"
  35.       CASE "ANS": D$ = "text file containing IBM ANSI display codes"
  36.       CASE "APL": D$ = "APL work space format file"
  37.       CASE "APP": D$ = "application file (SQLWindows)"
  38.       CASE "ARC": DetailedCheck% = -1
  39.       CASE "ARF": D$ = "response file created by a Microsoft compiler"
  40.       CASE "ARJ": D$ = "compressed library of files (ARJ)"
  41.       CASE "ASC": D$ = "ASCII (text) file"
  42.       CASE "ASM": D$ = "assembly language source code"
  43.       CASE "BAK": D$ = "backup copy of a file"
  44.       CASE "BAS": DetailedCheck% = -1
  45.       CASE "BAT": D$ = "executable code (DOS batch language)"
  46.       CASE "BI" : D$ = "includeable source code for compiled BASIC"
  47.       CASE "BIN": D$ = "binary data file"
  48.       CASE "BLK": D$ = "block info file (Show Partner)"
  49.       CASE "BMP": D$ = "picture file (MS Windows)"
  50.       CASE "C"  : D$ = "C source code"
  51.       CASE "CAL": D$ = "calendar data (MS Windows) or spreadsheet file (SuperCalc)"
  52.       CASE "CAP": D$ = "captions (Ventura Publisher)"
  53.       CASE "CCL": D$ = "comm command language file (Intalk)"
  54.       CASE "CDR": D$ = "picture (Corel Draw)"
  55.       CASE "CFG": D$ = "configuration, initialization or setup file"
  56.       CASE "CGM": D$ = "picture"
  57.       CASE "CHK": D$ = "file recovered by CHKDSK"
  58.       CASE "CHP": D$ = "chapter (Ventura Publisher)"
  59.       CASE "CIF": D$ = "chapter information (Ventura Publisher)"
  60.       CASE "CLR": D$ = "color palette (Show Partner)"
  61.       CASE "CLS": D$ = "class library file (Actor)"
  62.       CASE "CMD": D$ = "executable code (CP/M-86 or OS/2) or program (dBASE)"
  63.       CASE "CMP": D$ = "word comparison file (MS Word)"
  64.       CASE "CNF": D$ = "configuration, initialization or setup file"
  65.       CASE "COB": D$ = "COBOL source code"
  66.       CASE "COD": D$ = "FORTRAN compiled code"
  67.       CASE "COM": DetailedCheck% = -1
  68.       CASE "COL": D$ = "spreadsheet (MS Multiplan)"
  69.       CASE "CPL": D$ = "control panel applet (MS Windows)"
  70.       CASE "CPP": D$ = "C++ source code"
  71.       CASE "CRD": D$ = "index card file (MS Windows)"
  72.       CASE "CRF": D$ = "cross-reference listing"
  73.       CASE "CRS": D$ = "golf course data file (World Tour Golf)"
  74.       CASE "CTX": D$ = "course text file for a tutorial (Microsoft)"
  75.       CASE "CUR": D$ = "cursor definition (MS Windows)"
  76.       CASE "DAT": D$ = "data file"
  77.       CASE "DB" : D$ = "database file (Paradox)"
  78.       CASE "DBD": D$ = "demonstration data (Norton)"
  79.       CASE "DBF": D$ = "database file (dBASE)"
  80.       CASE "DBS": D$ = "database file (SQLWindows)"
  81.       CASE "DBT": D$ = "text file (dBASE)"
  82.       CASE "DCA": D$ = "text file (IBM)"
  83.       CASE "DCT": D$ = "spelling dictionary"
  84.       CASE "DEF": D$ = "definitions or defaults file"
  85.       CASE "DEV": D$ = "device driver"
  86.       CASE "DFM": D$ = "data entry form (Palantir Filer)"
  87.       CASE "DGI": D$ = "picture (Digi-Pic)"
  88.       CASE "DGS": D$ = "diagnostics file (PC-DOS)"
  89.       CASE "DIB": D$ = "device-independent bitmap (MS Windows)"
  90.       CASE "DIC": D$ = "spelling dictionary"
  91.       CASE "DIF": D$ = "data interchange format file"
  92.       CASE "DIR": D$ = "dialing directory (phone book)"
  93.       CASE "DIS": D$ = "start-up file (Q&A)"
  94.       CASE "DLL": D$ = "dynamic link library (MS Windows)"
  95.       CASE "DOC": D$ = "document, documentation or a manual (text file)"
  96.       CASE "DOT": D$ = "tutorial (Microsoft)"
  97.       CASE "DOX": D$ = "document (MultiMate)"
  98.       CASE "DRV": D$ = "device driver"
  99.       CASE "DRW": D$ = "picture (Micrografx)"
  100.       CASE "DTA": D$ = "data file"
  101.       CASE "DTF": D$ = "database (PFS or Q&A)"
  102.       CASE "DWC": D$ = "compressed library of files (DWC)"
  103.       CASE "EMU": D$ = "terminal emulation data (BITCOM)"
  104.       CASE "EPS": D$ = "picture (Encapsulated PostScript)"
  105.       CASE "ERR": D$ = "error code data"
  106.       CASE "EXE": DetailedCheck% = -1
  107.       CASE "FAC": D$ = "character font (LePrint)"
  108.       CASE "FLI": D$ = "animation file (Animator)"
  109.       CASE "FMT": D$ = "screen format (dBASE)"
  110.       CASE "FNT": D$ = "character font"
  111.       CASE "FON": D$ = "character font or phone book"
  112.       CASE "FOO": D$ = "temporary or miscellaneous file"
  113.       CASE "FOR": D$ = "FORTRAN source code"
  114.       CASE "FRM": D$ = "report layout (dBASE)"
  115.       CASE "GEM": D$ = "picture (GEM draw)"
  116.       CASE "GIF": D$ = "picture (CompuServe format)"
  117.       CASE "GRB": D$ = "snapshot or 'grab file' (MS Windows)"
  118.       CASE "GRF": D$ = "graph (Micrografx)"
  119.       CASE "GRP": D$ = "group definition (MS Windows)"
  120.       CASE "GUI": D$ = "guide document (Guide)"
  121.       CASE "GX1": D$ = "picture (Show Partner)"
  122.       CASE "H"  : D$ = "C header file"
  123.       CASE "HEX": D$ = "hex dump file (DEBUG)"
  124.       CASE "HLP": D$ = "help file"
  125.       CASE "HP" : D$ = "graphics (Hewlett-Packard)"
  126.       CASE "HPP": D$ = "C++ header file"
  127.       CASE "HXX": D$ = "C++ header file"
  128.       CASE "ICO": D$ = "icon definition (MS Windows)"
  129.       CASE "IDX": D$ = "index file"
  130.       CASE "IMG": D$ = "picture (GEM paint, ISF, WPS, et al)"
  131.       CASE "IMP": D$ = "implementation file (IBM Pascal)"
  132.       CASE "INC": D$ = "includeable source code"
  133.       CASE "INI": D$ = "configuration, initialization or setup file"
  134.       CASE "INF": D$ = "library definition file (LibWiz)"
  135.       CASE "INT": D$ = "implementation file (IBM Pascal) or command file (XyWrite)"
  136.       CASE "ION": D$ = "description of files"
  137.       CASE "IT" : D$ = "settings file (Intalk)"
  138.       CASE "JOR": D$ = "journal (SQLWindows)"
  139.       CASE "KBD": D$ = "keyboard configuration (XyWrite)"
  140.       CASE "KEX": D$ = "Kexx/Rexx source code (KEDIT)"
  141.       CASE "KEY": D$ = "keyboard definition file"
  142.       CASE "LAY": D$ = "keyboard configuration (SuperKey)"
  143.       CASE "LBL": D$ = "label description (dBASE)"
  144.       CASE "LBR": D$ = "library of files"
  145.       CASE "LIB": D$ = "linkable code library"
  146.       CASE "LST": D$ = "listing"
  147.       CASE "LZH": D$ = "compressed library of files"
  148.       CASE "MAC": D$ = "picture (MacIntosh) or keyboard macro (ProKey, SuperKey)"
  149.       CASE "MAN": D$ = "documentation or a manual"
  150.       CASE "MAP": D$ = "memory map (LINK)"
  151.       CASE "MDM": D$ = "modem information (Access)"
  152.       CASE "MEM": D$ = "memory file (dBASE)"
  153.       CASE "MID": D$ = "sound data in MIDI format (MS Windows)"
  154.       CASE "MNU": D$ = "menu definition (Access)"
  155.       CASE "MOD": D$ = "modifications list, Modula-2 source code, or music file"
  156.       CASE "MSG": D$ = "message file (MS Multiplan, Sidekick)"
  157.       CASE "MSP": D$ = "picture (MS Windows)"
  158.       CASE "NDX": D$ = "index file"
  159.       CASE "NET": D$ = "network configuration (Paradox)"
  160.       CASE "NEW": D$ = "new information (text)"
  161.       CASE "NOT": D$ = "notice (text)"
  162.       CASE "OBJ": D$ = "object code"
  163.       CASE "O"  : D$ = "object code (non-standard form)"
  164.       CASE "OLD": D$ = "backup file (Microsoft)"
  165.       CASE "OVD": D$ = "executable file (overlay for Paradox)"
  166.       CASE "OVL": D$ = "executable file (overlay)"
  167.       CASE "OVR": D$ = "executable file (overlay)"
  168.       CASE "PAK": DetailedCheck% = -1
  169.       CASE "PAL": D$ = "color palette (PC Paintbrush)"
  170.       CASE "PAS": D$ = "source code (Pascal)"
  171.       CASE "PCC": D$ = "picture (PC Paintbrush)"
  172.       CASE "PCT": D$ = "picture (MacIntosh)"
  173.       CASE "PCX": D$ = "picture (PC Paintbrush)"
  174.       CASE "PDF": D$ = "printer definitions (WordStar)"
  175.       CASE "PDV": D$ = "printer definitions (PC Paintbrush)"
  176.       CASE "PFM": D$ = "printer font metric (MS Windows)"
  177.       CASE "PGM": D$ = "executable file (overlay)"
  178.       CASE "PIC": D$ = "picture (Micrografx, Lotus 1-2-3)"
  179.       CASE "PIF": D$ = "program information (MS Windows)"
  180.       CASE "PIX": D$ = "picture(s)"
  181.       CASE "PJ" : D$ = "scheduling project (SuperProject)"
  182.       CASE "PM" : D$ = "picture (PageMaker)"
  183.       CASE "PM3": D$ = "picture (PageMaker v3.0)"
  184.       CASE "PRD": D$ = "printer definitions (MS Word)"
  185.       CASE "PRF": D$ = "spreadsheet printed to disk (VisiCalc)"
  186.       CASE "PRG": D$ = "dBASE source code"
  187.       CASE "PRJ": D$ = "project data (Harvard TPM)"
  188.       CASE "PRN": D$ = "printer definitions or print-format file"
  189.       CASE "PRO": D$ = "Prolog source code"
  190.       CASE "PRS": D$ = "printer definitions (WordPerfect)"
  191.       CASE "PS" : D$ = "page description (PostScript)"
  192.       CASE "PUB": D$ = "publication file (PageMaker)"
  193.       CASE "PX" : D$ = "primary index (Paradox)"
  194.       CASE "QLB": D$ = "MS Quick code library"
  195.       CASE "RC" : D$ = "resource script (MS Windows)"
  196.       CASE "REF": D$ = "cross-reference listing"
  197.       CASE "REX": D$ = "Rexx source code"
  198.       CASE "RTF": D$ = "Rich Text Format file (Microsoft)"
  199.       CASE "SC" : D$ = "Paradox source code"
  200.       CASE "SCN": D$ = "screen image"
  201.       CASE "SCP": D$ = "script file (BITCOM)"
  202.       CASE "SCR": D$ = "screen image, script language code, or high scores"
  203.       CASE "SET": D$ = "configuration, initialization or setup file"
  204.       CASE "SLD": D$ = "picture (AutoCAD)"
  205.       CASE "SLK": D$ = "Symbolic Link Format file"
  206.       CASE "STY": D$ = "style sheet (Ventura Publisher)"
  207.       CASE "SYM": D$ = "symbolic debugging definitions (MS Windows)"
  208.       CASE "SYN": D$ = "synonym file (Word Finder)"
  209.       CASE "SYS": D$ = "device driver"
  210.       CASE "TBK": D$ = "book file (ToolBook)"
  211.       CASE "TIF": D$ = "picture"
  212.       CASE "TMP": D$ = "temporary file"
  213.       CASE "TRM": D$ = "terminal program data (MS Windows)"
  214.       CASE "TXT": D$ = "text file"
  215.       CASE "VAL": D$ = "validity check file (Paradox)"
  216.       CASE "VC" : D$ = "spreadsheet (VisiCalc)"
  217.       CASE "VGR": D$ = "chapter information (Ventura Publisher)"
  218.       CASE "VOC": D$ = "sound file (SoundBlaster)"
  219.       CASE "VUE": D$ = "relational view (dBASE)"
  220.       CASE "WAV": D$ = "sound file (MS Windows)"
  221.       CASE "WCM": D$ = "communication file (MS Works)"
  222.       CASE "WDB": D$ = "database (MS Works)"
  223.       CASE "WK1": D$ = "spreadsheet (Lotus 1-2-3 v2)"
  224.       CASE "WKS": D$ = "spreadsheet (Lotus 1-2-3 v1a or MS Works)"
  225.       CASE "WMF": D$ = "picture (MS Windows)"
  226.       CASE "WPS": D$ = "text file (MS Works)"
  227.       CASE "WRI": D$ = "text file (MS Windows)"
  228.       CASE "XLC": D$ = "chart (Excel)"
  229.       CASE "XLS": D$ = "spreadsheet (Excel)"
  230.       CASE "XRF": D$ = "cross-reference listing"
  231.       CASE "ZIP": D$ = "compressed library of files (PKZIP)"
  232.       CASE "ZOO": D$ = "compressed library of files (ZOO)"
  233.       CASE ELSE
  234.    END SELECT
  235.  
  236.  
  237. CheckFile:
  238.    IF DetailedCheck% THEN
  239.       FOpen1 File$, 0, 2, Handle%, ErrCode%
  240.       IF ErrCode% THEN GOTO Done
  241.       SELECT CASE Extension$
  242.          CASE "ARC", "PAK"
  243.             St$ = SPACE$(1)
  244.             SFRead Handle%, St$, BR%, ErrCode%
  245.             FClose1 Handle%
  246.             IF ErrCode% THEN GOTO Done
  247.             IF ASC(St$) = 26 THEN D$ = "compressed library of files"
  248.          CASE "BAS"
  249.             D$ = "BASIC source code"
  250.             St$ = SPACE$(4)
  251.             SFRead Handle%, St$, BR%, ErrCode%
  252.             FClose1 Handle%
  253.             IF ErrCode% THEN GOTO Done
  254.             SELECT CASE ASC(St$)
  255.                CASE 255: D$ = "BASIC source code (interpreted, tokenized)"
  256.                CASE 254: D$ = "BASIC source code (interpreted, 'protected')"
  257.                CASE 253
  258.                   SELECT CASE CVI(RIGHT$(St$, 2))
  259.                      CASE &HA000: D$ = "picture (BASIC, EGA/VGA)"
  260.                      CASE &HB000: D$ = "picture (BASIC, MDA/Herc)"
  261.                      CASE &HB800: D$ = "picture (BASIC, CGA/Herc)"
  262.                      CASE ELSE: D$ = "binary memory image (BASIC)"
  263.                   END SELECT
  264.                CASE 252: D$ = "BASIC source code (QuickBASIC 4.x, tokenized)"
  265.                CASE 32 TO 126: D$ = "BASIC source code (text format)"
  266.                CASE ELSE
  267.             END SELECT
  268.          CASE "COM"
  269.             D$ = "executable code, COM-format"
  270.             St$ = SPACE$(15)
  271.             SFRead Handle%, St$, BR%, ErrCode%
  272.             FClose1 Handle%
  273.             IF ErrCode% THEN GOTO Done
  274.             IF LEFT$(St$, 2) = "MZ" THEN
  275.                Extension$ = "EXE"
  276.                GOTO CheckFile
  277.             END IF
  278.          CASE "EXE"
  279.             D$ = "executable code"
  280.             St$ = SPACE$(2)
  281.             SFRead Handle%, St$, BR%, ErrCode%
  282.             FClose1 Handle%
  283.             IF ErrCode% THEN GOTO Done
  284.             IF St$ = "MZ" THEN
  285.                D$ = "executable code, EXE-format"
  286.             ELSE
  287.                Extension$ = "COM"
  288.                GOTO CheckFile
  289.             END IF
  290.       END SELECT
  291.    END IF
  292.  
  293. Done:
  294.    Description$ = D$
  295.    DescriptionLen% = LEN(Description$)
  296.  
  297. END SUB
  298.