.TITLE IFMOD_RMS 'Fetch highest file modification date.' .IDENT /1.00/ ; --------------------------------------------------------------------------- ; IFMODRMS.MAR - The function of this routine is to accept a file name string ; a default name string, access all the files which match the file name ; string (via wildcarding), extract the modification date, and return ; the highest modification date found (newest modification date). ; ; Calling Procedure: ; ; status = IFMOD_RMS( file_str, def_str, mod_date, fnf, log ) ; ; Parameters: ; ; file_str - is the address of a string descriptor. The string must ; contain the file (with wildcards) that is to be accessed ; and the modification date returned for. If wildcards are ; included in the name then the highest modification date ; will be returned. ; ; def_str - is the address of a string descriptor. The string must ; contain the defaults to be used in parsing the file name ; string when fields are left blank. On return this will ; contain the resultant parsed string with all default fields ; supplied. It may be then be used for the next file spec. ; ; mod_date - is the address of a quad-word which contains the initial ; date to compare the modification dates of the files being ; processed. On exit it will contain a new value if one ; of the files processed had a higher modification date. ; ; fnf - is the address of a flag where the least significent bit is ; used to indicate whether File Not Found is considered an ; error or not. If it is considered an error then the file ; specification not found will be output in an error message ; and RMS$_FNF status will be returned. ; ; bit 0 = 0 - false - process RMS$_FNF as an error. ; bit 0 = 1 - true -- ignore RMS$_FNF errors. ; ; log - is the address of a flag where the least significent bit is ; used to indicate whether the modification date and the file ; name for each file process is to be logged or not. ; ; status - will contain SS$_NORMAL if everything goes ok, otherwise, it ; will contain the RMS error message number returned from the ; RMS function that returned it. ; ; --------------------------------------------------------------------------- ; .SBTTL Symbol definitions ; $RMSDEF $SSDEF ; FILE_STR = 4 DEF_STR = 8 MOD_DATE = 12 FNF = 16 LOG = 20 ; .SBTTL Writable data area. .PSECT IFMOD_WRITABLE,WRT,NOEXE ; IFMOD_FAB: $FAB NAM=IFMOD_NAM,- ; name block for wildcarding. FOP=NAM,- ; tell it to use name block. XAB=IFMOD_XABDAT,- ; ext atb blk for mod date. DNA=0,- ; def name str addr - dynamic. DNS=0,- ; def name str size - dynamic. FNA=0,- ; file name str adr - dynamic. FNS=0,- ; file name str adr - dynamic. FAC=,- ; specify readonly access. SHR= ; allow other readonly access. ; IFMOD_NAM: $NAM ESA=IFMOD_ESA,- ; Wildcard area addr. ESS=IFMOD_ESS,- ; wildcard area size. RSA=IFMOD_RSA,- ; Resultant name adr. RSS=IFMOD_RSS ; resultant name size. ; IFMOD_XABDAT: $XABDAT ; ext atb blk for mod date. ; ; ; IFMOD_ESS = 255 IFMOD_ESA: .BLKB IFMOD_ESS ; IFMOD_RSS = 255 IFMOD_RSA: .BLKB IFMOD_RSS .PAGE .SBTTL Executable area. .PSECT IFMOD_EXE,EXE,NOWRT ; .ENTRY IFMOD_RMS,^M ; MOVL FILE_STR(AP),R1 ; Get the file name descriptor. MOVZWL (R1),R2 ; Get the length of the string. ; MOVL DEF_STR(AP),R3 ; Get the def name descriptor. MOVZWL (R3),R4 ; Get the length of the string. ; $FAB_STORE - FAB=IFMOD_FAB, - ; FAB to fill in. FNA=@4(R1), - ; File name address. FNS=R2, - ; File name length. DNA=@4(R3),- ; Def name address. DNS=R4 ; Def name length. ; $PARSE FAB=IFMOD_FAB ; Parse the file name. BLBS R0,10$ ; good return BRW ERROR ; error; process the error. 10$: ; ; Return the expanded name string. ; MOVL DEF_STR(AP),R6 ; fetch address of def str desc MOVZBL IFMOD_NAM+NAM$B_ESL,- ; store length of def str. (R6) MOVC3 (R6),IFMOD_ESA,@4(R6) ; store the def str. ; ; Loop to wild card through the file(s) specified and return highest ; modification date. ; 100$: $SEARCH FAB=IFMOD_FAB ; Search dir for a file. CMPL #RMS$_NMF,R0 ; Any more files? BEQL RETURN ; No; Return BLBC R0,ERROR ; Other error; exit. ; $OPEN FAB=IFMOD_FAB ; open file to get mod date. BLBC R0,ERROR ; $CLOSE FAB=IFMOD_FAB ; close file. BLBC R0,ERROR ; MOVQ @MOD_DATE(AP),R6 ; Initialize compare date. ; CMPL IFMOD_XABDAT+XAB$Q_RDT+4,R7 ; Cmp high Lword of date. BLSSU 99$ ; Less; get next file. BGTRU 88$ ; Greater; store date. CMPL IFMOD_XABDAT+XAB$Q_RDT,R6 ; Equal; Cmp low Lword. BLEQU 99$ ; .le.; get next. 88$: MOVQ IFMOD_XABDAT+XAB$Q_RDT,R6 ; Save new high value. 99$: ; ; See if the file is to be logged along with its modification date. ; BLBC @LOG(AP),199$ ; If Clear, then skip logging ; ; set; log data. MOVL SP,R9 ; save the stack addr MOVZBL IFMOD_NAM+NAM$B_RSL,R8 ; fetch file name str length PUSHAL IFMOD_RSA ; push adr of file name str PUSHL R8 ; push lenght of file name str ; PUSHL SP ; push adr of dyn str desc PUSHAL IFMOD_XABDAT+XAB$Q_RDT ; push adr of mod date. PUSHL #2 ; push number of arguments PUSHL #IPSS$IFM_LOG ; push message number. CALLS #4,G^LIB$SIGNAL ; Log the date and file. MOVL R9,SP ; restore the stack addr 199$: ; BRW 100$ ; Loop to process next file. ; ; Exit. ; RETURN: MOVL #SS$_NORMAL,R0 ; No more files. MOVQ R6,@MOD_DATE(AP) ; Store highest value found. RET ; Return to caller. ; ; --- ; ; Issue error message with file spec and return error code. ; ERROR: MOVL R0,R6 ; Save error code. ; CMPL #RMS$_FNF,R0 ; File not found error? BNEQ 15$ ; No; log error message. ; ; is /FNF set? BLBC @FNF(AP),15$ ; no; error ; ; If /LOG then log the file not found as informational message. ; ; ; is /LOG set? BLBC @LOG(AP),40$ ; no; return ; MOVZBL IFMOD_NAM+NAM$B_RSL,R8 ; fetch result src length PUSHAL IFMOD_RSA ; push adr of result string PUSHL R8 ; push length of string. MOVL SP,R7 ; save addr of descriptor. PUSHL R7 ; push adr of result str desc PUSHL #1 ; push number of arguments PUSHL #IPSS$IFM_FNF ; push file not found log num CALLS #3,G^LIB$SIGNAL ; issue file not found log msg. BRW 40$ ; exit 15$: ; ; Create a string descriptor on the stack. ; MOVZBL IFMOD_NAM+NAM$B_RSL,R8 ; fetch result src lenght. CMPL #0,R8 BEQL 20$ ; PUSHAL IFMOD_RSA ; push address of result string PUSHL R8 ; push length of result string MOVL SP,R7 ; save address of descriptor BRB 30$ 20$: MOVL FILE_STR(AP),R7 ; Get the file name descriptor. 30$: ; ; Call LIB$SIGNAL to issue the error message. ; PUSHL R7 ; push adr of result str desc. PUSHL #1 ; push number of arguments. PUSHL #IPSS$IFM_FILEERR ; push error message number. CALLS #3,G^LIB$SIGNAL ; issue the error message. ; 40$: MOVL R6,R0 ; Restore error code. RET ; Return with error. ; .END