; ; LULIB Module: LUOPEN ; Author: Richard Conn ; Date: 8 August 85 ; LULIB Version: 1.0 ; LULIB Module Version: 1.0 ; public luopen,ludate,lumdate,lutime,lumtime ; ; LUOPEN opens a file within a library for reading. It locates ; the file and loads the appropriate buffers in the LUD for following ; reads. ; On input, DE = ptr to LUD and HL = ptr to FN.FT ; On output, A is return code: ; 0 OK ; 0FFH File Not Found ; ; Side Effect: DMA Address is set to TBUFF ; ; March 23, 1991. Added two more public buffers, LUTIME and LUMTIME, ; to contain the MSDOS-format create and modify times, respectively. ; Moved included definitions into the module. Howard Goldstein ; ; October 14, 1989. Added another 2-byte buffer, LUMDATE, to store the ; modify date from the LBR member. The create date is still stored in ; LUDATE. Howard Goldstein ; ; March 25, 1988, special version for obtaining date information, ; now resembles SYSLIB4's SLUOPEN except that the DRI-format date ; is extracted and stored in the public 2-byte buffer LUDATE. ; Because of the new "@afncm" external, SYSLIB4 is required for ; linkage completion. ; Bruce Morgen ; ; Externals ; extrn f$open,r$read,setdma,@afncmp bdose equ 5 tbuff equ 80h ludfcb equ 11h ; offset to FCB in LUD luidx equ 0ch ; offset to index in LBR directory entry luopen: push hl ; save regs push de push bc ld (file),hl ; save ptr to file name ld hl,tbuff call setdma ld hl,ludfcb ; offset to FCB add hl,de ex de,hl ; DE = FCB push hl ; save ptr to LUD ld c,(hl) ; get length of directory inc hl ld b,(hl) ld hl,0 ; read directory in (record 0) loop: call r$read ; random read jr nz,error ; file not found if error push de ; save key regs push bc call scan ; scan for file name match pop bc ; restore key regs pop de jr z,match inc hl ; pt to next record dec bc ; count down length of dir ld a,b ; done? or c jr nz,loop error: pop hl ; restore LUD ptr or 0ffh ; set 0FFH done: pop bc ; restore regs pop de pop hl or a ; set flags ret ; ; Match - HL pts to entry ; Copy index and length into LUD ; match: ld (ludent),hl ; save ptr to LUD entry ld de,luidx ; offset to index add hl,de ; HL pts to index pop de ; DE pts to LUD inc de ; DE pts to index in LUD inc de ld bc,4 ; copy index and length into LUD ldir ; copy inc hl inc hl push de ld de,ludate ld c,8 ldir pop de ld hl,(ludent) ; get ptr to LUD entry inc hl ; pt to file name ld c,11 ; 11 bytes to copy ldir ; copy xor a ; A=0 jr done ; ; Scan TBUFF for file name ; If found, A=0 and HL pts to entry ; If not found, A=0FFH ; scan: push hl ; save regs ld hl,tbuff ; pt to buffer ld c,4 ; 4 entries possible scan1: ld a,(hl) ; check for active entry or a ; 0=yes jr nz,scanxt push hl inc hl ; pt to name ld de,(file) ; pt to file name ld b,11 ; 11 bytes push bc ex de,hl call @afncmp pop bc jr nz,scanlp2 pop hl ; we have a match - pt to entry with HL pop af ; flush old HL xor a ; return with zero for match ret scanlp2: pop hl ; pt to current scanxt: ld de,32 ; pt to next add hl,de dec c ; count down jr nz,scan1 pop hl ; restore HL or 0ffh ; set no match ret ; dseg ; Buffers ; file: ds 2 ; pointer to FN.FT ludent: ds 2 ; pointer to LUD entry ludate: ds 2 ; DRI-format create date lumdate: ds 2 ; DRI-format modify date lutime: ds 2 ; MSDOS-format create time lumtime: ds 2 ; MSDOS-format modify time end