PROGRAM FILEINFO * By David A. Green - 4/27/01 * DAG Consulting Version="~Ver=~6.5.68~-1885830095~" * dgreen@dagconsulting.com REM REM This program is freeware, on the condition that the TITLE not be changed. REM Please submit any enhancement request to dgreen@dagconsulting.com REM EQUATE TRUE TO 1, FALSE TO 0 * EQUATE ReadBit TO 4 EQUATE WritBit TO 2 EQUATE ExecBit TO 1 * GOSUB GET.PA GOSUB INIT LOOP READNEXT FILE.NAME ELSE DONE.FLAG = TRUE UNTIL DONE.FLAG DO GOSUB FILE.INIT GOSUB OPEN.FILE IF NOT(BAD.FILE.FLAG) THEN GOSUB GET.FILE.INFO GOSUB PRINT.FILE.INFO PAGE REPEAT * STOP ! GET.PA: CMDS = FIELD(@SENTENCE, " ", 2, 999) IF CMDS THEN SWAP " " WITH @AM IN CMDS FORMLIST CMDS END RETURN ! FILE.INIT: NOTES = "" OS.FLAG = FALSE HASH.FLAG = FALSE DYN.FLAG = FALSE STATIC.FLAG = FALSE DIR.FLAG = FALSE SEQ.FLAG = FALSE INDEX.FLAG = FALSE DICT.FLAG = FALSE FILE.CNT = 0 REC.CNT = 0 VOC.NAME = "" DATE.LAST.MOD = "" TIME.LAST.MOD = "" HEADING "File information for ":FILE.NAME:"'G'Page 'P'" RETURN ! INIT: PROMPT "" PERFORM "UDT.OPTIONS 64 ON" ;* Display last FOOTING. PERFORM "TERM 79,23" PRINT @(-1): BPIOCP HEADING "File information'G'Page 'P'" FOOTING "Copyright 2001 DAG Consulting, www.dagconsulting.com" DONE.FLAG = FALSE NT.FLAG = FALSE UNIX.FLAG = FALSE BEGIN CASE CASE SYSTEM(33) = "Windows NT" ; NT.FLAG = TRUE CASE SYSTEM(33) = "UNIX" ; UNIX.FLAG = TRUE CASE 1 END CASE DONE.CMDS = "":@VM:"END":@VM:"Q":@VM:"QUIT" TITLE = "FILE.INFO By DAG Consulting 480-201-7953 (www.dagconsulting.com)" FMT.SIZE = "15R," RETURN ! OPEN.FILE: IF FILEINFO(F.FILE, 0) THEN CLOSE F.FILE BAD.FILE.FLAG = FALSE BEGIN CASE CASE INDEX(FILE.NAME, ",", 1) ; GOSUB OPEN.SEQ.FILE CASE INDEX(FILE.NAME, "/", 1) ; GOSUB OPEN.OS.FILE CASE INDEX(FILE.NAME, "\", 1) ; GOSUB OPEN.OS.FILE CASE 1 ; GOSUB OPEN.UNI.FILE END CASE RETURN ! OPEN.SEQ.FILE: OPENSEQ FILE.NAME TO F.FILE ELSE NULL RETURN ! OPEN.OS.FILE: OSOPEN FILE.NAME TO F.FILE ELSE GOSUB OPEN.ERROR RETURN ! OPEN.UNI.FILE: OPEN FILE.NAME TO F.FILE ELSE GOSUB OPEN.ERROR OPEN "DICT", FILE.NAME TO D.FILE THEN DICT.FLAG = TRUE RETURN ! OPEN.ERROR: BAD.FILE.FLAG = TRUE RETURN ! GET.FILE.INFO: FILE.CNT += 1 BEGIN CASE CASE FILEINFO(F.FILE, 3) = 2 ; FILE.TYPE = "Static Hashed" ; HASH.FLAG = TRUE ; STATIC.FLAG = TRUE CASE FILEINFO(F.FILE, 3) = 3 ; FILE.TYPE = "Dynamic Hashed" ; HASH.FLAG = TRUE ; DYN.FLAG = TRUE CASE FILEINFO(F.FILE, 3) = 4 ; FILE.TYPE = "Directory" ; DIR.FLAG = TRUE CASE FILEINFO(F.FILE, 3) = 5 ; FILE.TYPE = "Sequential" ; SEQ.FLAG = TRUE CASE FILEINFO(F.FILE, 3) = 7 ; FILE.TYPE = "NFA" CASE FILEINFO(F.FILE, 3) = 8 ; FILE.TYPE = "OS" ; OS.FLAG = TRUE CASE 1 ; FILE.TYPE = "Unknown" END CASE FILE.PATH = FILEINFO(F.FILE, 2) VOC.NAME = FILEINFO(F.FILE, 17) BEGIN CASE CASE INDEX(FILE.PATH, "/", 1) ; OS.DELM = "/" CASE INDEX(FILE.PATH, "\", 1) ; OS.DELM = "\" CASE 1 ; OS.DELM = "" END CASE IF FILEINFO(F.FILE, 13) THEN INDEX.FLAG = TRUE GOSUB GET.FILE.SIZE PERMISSIONS = FILEINFO(F.FILE, 19) IF UNIX.FLAG OR NT.FLAG THEN PERM = OCONV(PERMISSIONS, "MB")[3] ; PERMISSIONS = "" IF BITAND(PERM, ReadBit) THEN PERMISSIONS<-1> = "Read" IF BITAND(PERM, WritBit) THEN PERMISSIONS<-1> = "Write" IF BITAND(PERM, ExecBit) THEN PERMISSIONS<-1> = "Execute" SWAP @AM WITH "/" IN PERMISSIONS END IF HASH.FLAG THEN IF FILEINFO(F.FILE, 22) THEN NOTES := "Recoverable" END ELSE NOTES := "Non-Recoverable" END NOTES := " file has " IF INDEX.FLAG THEN NOTES := "an" ELSE NOTES := "no" NOTES := " Index. " END RETURN ! PRINT.FILE.INFO: PRINT IF FILEINFO(F.FILE, 0) THEN PRINT "Pathname " : FILE.PATH IF VOC.NAME THEN PRINT "VOC Name " : VOC.NAME PRINT "File Type " : FILE.TYPE IF HASH.FLAG THEN PRINT "Hash Type " : FILEINFO(F.FILE, 4) PRINT "Modulo " : FILEINFO(F.FILE, 5) PRINT "Group Size " : FILEINFO(F.FILE, 7) PRINT "Block Size " : FILEINFO(F.FILE, 8) END IF DYN.FLAG THEN PRINT "Min Modulo " : FILEINFO(F.FILE, 6) PRINT "Merge % " : FILEINFO(F.FILE, 9) PRINT "Split % " : FILEINFO(F.FILE, 10) PRINT "Load % " : FILEINFO(F.FILE, 11) END IF DIR.FLAG THEN PRINT "Block Size " : FILEINFO(F.FILE, 18) END PRINT "Last Mod " : OCONV(DATE.LAST.MOD, "D2-") : " " : OCONV(TIME.LAST.MOD, "MTH") PRINT "Permissions " : PERMISSIONS IF NOTES THEN PRINT NOTES IF TOTL.SIZE THEN PRINT "--------[ Disk Usage ]--------" IF DATA.SIZE THEN PRINT "Data.......... " : DATA.SIZE FMT.SIZE IF DICT.SIZE THEN PRINT "Dictionary.... " : DICT.SIZE FMT.SIZE IF INDX.SIZE THEN PRINT "Index......... " : INDX.SIZE FMT.SIZE IF TOTL.SIZE # DATA.SIZE THEN PRINT "Total......... " : TOTL.SIZE FMT.SIZE END ELSE PRINT "Not a valid File." END RETURN ! GET.FILE.SIZE: DATA.SIZE = 0 DICT.SIZE = 0 INDX.SIZE = 0 TOTL.SIZE = 0 BEGIN CASE CASE STATIC.FLAG ; GOSUB GET.STATIC.SIZE CASE DYN.FLAG ; GOSUB GET.DYN.SIZE CASE OS.FLAG ; GOSUB GET.OS.SIZE CASE DIR.FLAG ; GOSUB GET.DIR.SIZE END CASE TOTL.SIZE = DATA.SIZE + DICT.SIZE + INDX.SIZE RETURN ! GET.DIR.SIZE: SELECT F.FILE DIR.DONE = FALSE REC.CNT = 0 LOOP READNEXT DIR.KEY ELSE DIR.DONE = TRUE UNTIL DIR.DONE DO REC.CNT += 1 OS.PATH = FILE.PATH:OS.DELM:DIR.KEY GOSUB GET.OS.FILE.SIZE DATA.SIZE += OS.FILE.SIZE REPEAT OS.PATH = FILE.PATH GOSUB GET.OS.FILE.SIZE DATE.LAST.MOD = OS.DATE.LAST.MOD TIME.LAST.MOD = OS.TIME.LAST.MOD NOTES := "File has ":TRIM(REC.CNT "15R,"):" Items. " RETURN ! GET.OS.SIZE: OS.PATH = FILE.PATH GOSUB GET.OS.FILE.SIZE DATA.SIZE = OS.FILE.SIZE DATE.LAST.MOD = OS.DATE.LAST.MOD TIME.LAST.MOD = OS.TIME.LAST.MOD RETURN ! GET.STATIC.SIZE: OS.PATH = FILE.PATH GOSUB GET.OS.FILE.SIZE DATA.SIZE = OS.FILE.SIZE DATE.LAST.MOD = OS.DATE.LAST.MOD TIME.LAST.MOD = OS.TIME.LAST.MOD GOSUB GET.DICT.SIZE PATH.CNT = DCOUNT(FILE.PATH, OS.DELM) INDEX.PATH = FIELD(FILE.PATH, OS.DELM, 1, PATH.CNT-1) INDEX.PATH := OS.DELM:"X_":FIELD(FILE.PATH, OS.DELM, PATH.CNT) OS.PATH = INDEX.PATH GOSUB GET.OS.FILE.SIZE INDX.SIZE = OS.FILE.SIZE RETURN ! GET.DYN.SIZE: DATE.LAST.MOD.LATTER = 0 DYN.DONE = FALSE FOR DYN.CNT = 1 TO 256 UNTIL DYN.DONE OS.PATH = FILE.PATH:OS.DELM:"dat":FMT(DYN.CNT, "3\0R") GOSUB GET.OS.FILE.SIZE DATA.SIZE += OS.FILE.SIZE IF OS.DATE.LAST.MOD > DATE.LAST.MOD.LATTER THEN DATE.LAST.MOD.LATTER = OS.DATE.LAST.MOD TIME.LAST.MOD.LATTER = OS.TIME.LAST.MOD END IF OS.FILE.INFO = "" THEN DYN.DONE = TRUE END ELSE OS.PATH = FILE.PATH:OS.DELM:"over":FMT(DYN.CNT, "3\0R") GOSUB GET.OS.FILE.SIZE DATA.SIZE += OS.FILE.SIZE OS.PATH = FILE.PATH:OS.DELM:"idx":FMT(DYN.CNT, "3\0R") GOSUB GET.OS.FILE.SIZE INDX.SIZE += OS.FILE.SIZE END NEXT DYN.CNT GOSUB GET.DICT.SIZE DATE.LAST.MOD = DATE.LAST.MOD.LATTER TIME.LAST.MOD = TIME.LAST.MOD.LATTER RETURN ! GET.DICT.SIZE: IF DICT.FLAG THEN OS.PATH = FILEINFO(D.FILE, 2) GOSUB GET.OS.FILE.SIZE DICT.SIZE = OS.FILE.SIZE END RETURN ! GET.OS.FILE.SIZE: OS.FILE.INFO = DIR(OS.PATH) OS.FILE.SIZE = OS.FILE.INFO<1> OS.DATE.LAST.MOD = OS.FILE.INFO<2> OS.TIME.LAST.MOD = OS.FILE.INFO<3> OS.PERMISSIONS = OS.FILE.INFO<4> RETURN ! END