.MCALL .MODULE .MODULE SDIR,RELEASE=V02,VERSION=00,COMMENT=,AUDIT=YES .ENABLE LC ; SDIR will display the directory of any subdevice file. ; The assumed subdevice file type is .DSK. ; A default device is stored at DFTDEV:: and it will be ; used unless the user provides a device name. ; The normal default is SY: ; ; SDIR filespec ; filespec is the name of the subdevice file ; Author: ; D. N. Tanner ; Livermore, Ca 94550 .MCALL .PRINT, .EXIT, .CLOSE, .SERR, .GTLIN, .TTYIN, .CSIGEN .GLOBL SDIR, IOASC, INDEX .GLOBL DATEI, GETFIL, R50ASC, IRAD50 DEVTYP:: .RAD50 /DSK/ ;Default subdevice file type .WORD 0,0,0 PAGSIZ:: .WORD 21. TERTYP:: .WORD 1. ;0 none, 1=VT100, 2=VT52 .BYTE 0 FILN: .ASCII /=/ DFTDEV:: .ASCII /SY: / .WORD 0,0,0,0,0,0,0,0,0,0 ;File name space HNDLR: .BLKW 1200. ;Space for device handlers SDIR:: MOV #100.,LINE ;Line count, force a new page .GTLIN #FILNAM,#GREET ;Get the file name line. TSTB FILNAM ;Was a line typed? BEQ EXIT ;no, quit. MOV #ARG9,R5 JSR PC,INDEX ;Look for a : (Device input) MOV #DFTDEV,R2 ;Pointer for file name TST R0 BNE 4$ ;found, use it 1$: CMPB (R2)+,#': ;use default, look for the colon BNE 1$ ; and skip past it 4$: MOV #FILNAM,R1 ;Input file name pointer 5$: MOVB (R1)+,(R2)+ ;Copy name to output BNE 5$ .CSIGEN #HNDLR, #DEVTYP, #FILN BCS ERR MOV #3.,CHAN CLR BLKEY ;no dir block in memory 2$: MOV #ARG4,R5 JSR PC,GETFIL ;Get the next file from the current device TST IFLG BGT 10$ ;End of this directory BLT ABORT INC FILCNT ;Count the file JSR PC, PFILE ;print the file information BR 2$ ;Next file 10$: .CLOSE CHAN TST FILCNT ;Did we find any files? BEQ 20$ ;No, the count is zero MOV #ARG5,R5 JSR PC, IOASC ;Convert file count to ASCII MOV #ARG6, R5 JSR PC, IOASC ;Convert block count to ASCII .PRINT #TOTMSG ;Print the total line MOV #ARG7, R5 JSR PC, IOASC MOV #ARG8, R5 JSR PC, IOASC .PRINT #USEDMG ;# free blocks .EXIT 20$: .PRINT #NOFIL ;Tell user no files found EXIT: .EXIT ERR: MOVB @#52,R0 ;get the error byte BEQ ERR0 CMPB R0,#1 BEQ ERR1 .PRINT #MSG2 BR NXT ERR0: .PRINT #MSG0 ;bad file name BR NXT ERR1: .PRINT MSG1 ;device not found BR NXT ABORT: .PRINT #MSG3 ;abort error NXT: .CLOSE CHAN .EXIT .PAGE ; PFILE ; Prints current file name on the terminal. PFILE: MOV #P1,R5 ;File Date JSR PC,DATEI MOV #P2,R5 ;File size JSR PC,IOASC 2$: TST PAGSIZ ;Skip the heading and the page if ;Pagsiz is set to zero BEQ 3$ CMP LINE,PAGSIZ BLT 3$ CMP LINE,#100. ;Is this the first time thru. BEQ 6$ ;Prompt for continue message .PRINT #CONT ; Wait for a return 7$: .TTYIN CMPB R0,#12 ;Look for a line feed BNE 7$ ;continue waiting 6$: CMP TERTYP,#1 BLT 4$ BGT 5$ .PRINT #VT100 BR 4$ 5$: .PRINT #VT52 4$: .PRINT #H1 .PRINT #FILNAM .PRINT #H2 MOV #3,LINE 3$: INC LINE MOV #P5,R5 ;File name JSR PC,R50ASC MOV #P6,R5 JSR PC,R50ASC .PRINT #FN1 RTS PC .NLIST BIN P1: .WORD 2, FDAT, DATE P2: .WORD 3, SIZE, N4, FSIZ P5: .WORD 3, N6, NAME, FN1 P6: .WORD 3, N3, TYPE, FT1 ESC=33 VT100: .ASCII /[2J//[H/<200> VT52: .ASCII /E//H/<200> H1: .ASCII /Directory for: /<200> H2: .ASCIZ /File Name Size Date/ CONT: .ASCII /Continue .../<200> .EVEN NOFIL: .ASCII /No Files Found in the sub-directory file/<15><12><0> ; abcdef.typ 123456 10-Oct-86 FN1: .ASCii / ./ FT1: .ASCII / / .ASCII / / FSIZ: .ASCII / / FDAT: .ASCII / - - / .BYTE 0,0 .EVEN .PAGE .NLIST BIN ;DATA AREA LINE: .WORD 0 ;Screen line counter ZERO: .WORD 0 ;constant IFLG: .WORD 0 ;flag N3: .WORD 3. ;Constant N4: .WORD 4. ;Constant N5: .WORD 5. ;Constant N6: .WORD 6. ;Constant FILCNT: .WORD 0 ;Number of files ARG4: .WORD 1, IFLG ARG9: .WORD 2, FILNAM, COLON ;File total and block count message area ARG5: .WORD 3, FILCNT, N4, MSGCNT ARG6: .WORD 3, TUSED, N5, MSGSIZ ARG7: .WORD 3, TFREE, N5, USEDMG ARG8: .WORD 3, MFREE, N5, MAXMSG TOTMSG: .ASCII <15><12> ; 1234 Files 12345 Blocks MSGCNT: .ASCII / / .ASCII / Files / MSGSIZ: .ASCIZ / Blocks/ ; 12345 Free blocks, Largest free area is 12345 Blocks USEDMG: .ASCII / Free blocks, Largest free area is / MAXMSG: .ASCII / Blocks/ .BYTE 200,0 .EVEN GREET: .ASCII /SDIR V02.00> /<200> .EVEN COLON: .ASCIZ /:/ MSG0: .ASCIZ /SDIR-F- Bad File name/ MSG1: .ASCIZ /SDIR-F- Device not found/ MSG2: .ASCIZ /SDIR-F- File Not Found/ MSG3: .ASCIZ /SDIR-F- File is not a sub-device/ .EVEN FILNAM: .BLKB 80. .WORD 0 ; COMMON /FILE/ Used by GETFIL routine .PSECT FILE,GBL,OVR,D NAME: .BLKW 2 TYPE: .BLKW 1 DATE: .BLKW 1 SIZE: .BLKW 1 CHAN: .BLKW 1 ; BLKEY - Directory block in memory, 0 means no block. BLKEY: .BLKW 1 TUSED: .WORD 0 ;Total number of blocks used TFREE: .WORD 0 ;Total number of free blocks MFREE: .WORD 0 ;Largest free area .END SDIR