SUBROUTINE GET_DIR_INFO(ANSWER, INPUT.TYPE, FILE.NAME, ITEM.NAME, FLAG) * By David A. Green -- 9/06/02 -- www.dagconsulting.com * Retrieves DIR Type files Date, Time, Size, Permissions * Valid INPUT.TYPES are: DATE, TIME, SIZE, PERM * Errors are reported in FLAG * Output is in ANSWER * COMMON /GETDIR/ GETDIR.REC(10) EQUATE GETDIR.FLAG TO GETDIR.REC( 1) EQUATE F.FILE TO GETDIR.REC( 2) EQUATE LAST.FILE TO GETDIR.REC( 3) * GOSUB INIT * IF FILE.NAME # LAST.FILE THEN GOSUB OPEN.FILE IF FILEINFO(F.FILE, 0) = 0 THEN GOSUB OPEN.FILE IF NOT(FLAG) THEN FILE.PATH = FILEINFO(F.FILE, 2):OS.DELM:ITEM.NAME * FILE.INFO = DIR(FILE.PATH) FILE.SIZE = FILE.INFO<1> DATE.LAST.MOD = FILE.INFO<2> TIME.LAST.MOD = FILE.INFO<3> PERMISSIONS = FILE.INFO<4> * BEGIN CASE CASE INPUT.TYPE = "SIZE" ; ANSWER = FILE.SIZE CASE INPUT.TYPE = "DATE" ; ANSWER = DATE.LAST.MOD CASE INPUT.TYPE = "TIME" ; ANSWER = TIME.LAST.MOD CASE INPUT.TYPE = "PERM" ; ANSWER = PERMISSIONS CASE 1 ; FLAG = "Invalid Type Request ":DQUOTE(INPUT.TYPE) END CASE END ! RETURN ! INIT: INPUT.TYPE = UPCASE(INPUT.TYPE) ANSWER = "" FLAG = "" BEGIN CASE CASE SYSTEM(33) = "UNIX" ; OS.DELM = "/" CASE SYSTEM(33) = "WINDOWS NT" ; OS.DELM = "\" CASE 1 ; OS.DELM = "/" END CASE * IF FILE.NAME = "" THEN FILE.NAME = FIELD(@SENTENCE, " ", 2) END * IF GETDIR.FLAG # @WHO:@DATE THEN CLOSE F.FILE RETURN ! OPEN.FILE: OPEN FILE.NAME TO F.FILE ELSE FLAG = "Can't open ":FILE.NAME RETURN END LAST.FILE = FILE.NAME GETDIR.FLAG = @WHO:@DATE RETURN ! END