TITLE "Z3PFIND - Z3LIB 4.5A" NAME ('Z3PFIND') ;================================================================ ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;---------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from Z3PFIND.Z80 Ver 1.1 by Richard Conn ; Date : 20 Sep 93 ; Version : 1.5 ; Module : Z3PFIND ; Abstract: This module contains the routine PFIND which searches ; along the path for a specified file. If found, the drive ; and user numbers are returned. If not found, error codes ; containing the reason are returned ; Revision: ; 1.5 - 20 Sep 93 - Search 1st path element if No search of ; current DU and 1st element is $$. Hal Bower ; 1.4 - 2 May 92 - Corrected Bombing if No Path. Hal Bower ; 1.3 - 25 Aug 90 - Shortened it up a lot. Joe Wright ; 1.2 - 29 Mar 89 - Original Ver 4 Release. Hal Bower ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC PFIND ; External References EXT GETPATH, LOGUD, RETUD, @BDOS .Z80 CSEG ;=============================================================== ; NAME - PFIND ; Entry: DE - Points to an FCB for file to locate ; A = 0 if No current search, <> 0 if current search ; Exit : BC = Drive/User. B = Disk, C = User if found ; A <> 0, Zero Flag Reset (NZ) if Found ; A = 0, Zero Set (Z) if NOT Found ; Uses : AF,BC ; Special Requirements: None ;=============================================================== PFIND: PUSH HL ; Save caller's HL PUSH AF ; Save search current flag CALL RETUD ; Get current Disk & User in BC LD (CUSER),BC ; .save in Current DU LD HL,0FFFFH LD (TUSER),HL ; Set Temp DU to dummy for 1st elem access CALL GETPATH ; Get address of external path in HL POP AF ; Restore Search current flag OR A ; Search Current DU? (0=No) JR NZ,PF1 ; ..jump if So PF0: LD A,H OR L ; Any Path Defined? JR Z,PFERRX ;1.4 ..jump to Exit w/Zero if Not ; Get Path element to BC skipping adjacent duplicates if Path Exists. ; Return NZ if we have a new element. GETDU: LD A,(HL) ; Get Drive OR A ; Anything there? JR Z,PFNDX ; ..jump to Exit if No more Path INC HL ; Else bump pointer LD BC,(CUSER) ; Get Current DU CP '$' ; Current Drive? JR Z,GET1 ; ..jump if So DEC A ; Else make Drive in [0..15] LD B,A GET1: LD A,(HL) ; Get User INC HL ; .(bump) CP '$' ; Current User? JR Z,GET2 ; ..jump if So LD C,A GET2: PUSH HL ; Free up HL a moment LD HL,(TUSER) ; Get Last DU (or -1) OR A SBC HL,BC ; Same as Last DU? POP HL JR Z,GETDU ; ..jump to get another if So CALL LOGUD ; Else log the new DU ; Look for file whose FCB is pted to by DE PF1: LD (TUSER),BC ; Save Current DU for Next Try LD C,17 ; Search First PUSH HL ; ..save Path address CALL @BDOS POP HL ; ..restore path addr INC A ; File found? JR Z,PF0 ; ..jump if Not to Try again ; Fall into PFNDX if Found, return to caller PFNDX: LD BC,(CUSER) ; Current DU CALL LOGUD LD BC,(TUSER) ; In case it was found PFERRX: POP HL RET ;..... ; Internal Data Area Storage Buffers DSEG ; Put in Data segment CUSER: DEFS 2 ; Current User/Drive TUSER: DEFS 2 ; Temp User/Drive END