1 ; SCCSID = @(#)isearch.asm 1.1 85/04/10
2 TITLE DOS_SEARCH
- Internal SEARCH calls for
MS-DOS
4 ; Low level routines for doing local and NET directory searches
12 ; Created: ARR 30 March 1983
13 ; A000 version 4.00 Jan. 1988
14 ; A001 PTM 3564 -- serach for fastopen
17 ; get the appropriate segment definitions
22 CODE SEGMENT BYTE PUBLIC 'CODE'
23 ASSUME
SS:DOSGROUP
,CS:DOSGROUP
49 i_need EXTERR_LOCUS
,BYTE
50 i_need FastopenFlg
,BYTE
51 I_need DOS34_FLAG
,WORD
54 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
56 ; [CURR_DIR_END] Points to end of Current dir part of string
57 ; ( = -1 if current dir not involved, else
58 ; Points to first char after last "/" of current dir part)
59 ; [THISCDS] Points to CDS being used
60 ; (Low word = -1 if NUL CDS (Net direct request))
61 ; [SATTRIB] Is attribute of search, determines what files can be found
62 ; [DMAADD] Points to 53 byte buffer
64 ; Initiate a search for the given file spec
67 ; The 53 bytes ot DMAADD are filled in as follows:
70 ; Drive Byte (A=1, B=2, ...) High bit clear
71 ; NEVER STORE DRIVE BYTE AFTER found_it
72 ; 11 byte search name with Meta chars in it
73 ; Search Attribute Byte, attribute of search
77 ; 32 bytes of the directory entry found
79 ; 21 bytes First byte has high bit set
80 ; 32 bytes of the directory entry found
85 ; No match for this file
86 ; error_path_not_found
87 ; Bad path (not in curr dir part if present)
89 ; Bad path in current directory part of path
90 ; DS preserved, others destroyed
92 procedure DOS_SEARCH_FIRST
,NEAR
93 DOSAssume
CS,<DS>,"DOS_Search_First"
100 transfer NET_SEQ_SEARCH_FIRST
102 MOV AX,(multNET
SHL 8) OR 25
108 TEST ES:[DI.curdir_flags
],curdir_isnet
109 JZ LOCAL_SEARCH_FIRST
111 transfer NET_SEARCH_FIRST
113 MOV AX,(multNET
SHL 8) OR 27
120 TEST [DOS34_FLAG
],SEARCH_FASTOPEN
;AN000;
122 OR [FastOpenflg
],Fastopen_Set
;AN000;
124 MOV [NoSetDir
],1 ; if we find a dir, don't change to it
125 CALL CHECK_QUESTION
;AN000;;FO. is '?' in path
126 JNC norm_getpath
;AN000;;FO. no
127 AND [FastOpenflg
],Fast_yes
;AN000;;FO. reset fastopen
136 MOV AX,error_no_more_files
138 AND CS:[FastOpenflg
],Fast_yes
;AN000;;FO. reset fastopen
145 MOV AX,error_path_not_found
151 MOV [LastEnt
],-1 ; Cause DOS_SEARCH_NEXT to fail
152 INC [Found_Dev
] ; Tell DOS_RENAME we found a device
155 ; We set the physical drive byte here Instead of after found_it; Doing
156 ; a search-next may not have wfp_start set correctly
159 MOV SI,WFP_Start
; get pointer to beginning
161 SUB AL,'A'-1 ; logical drive
162 STOSB ; High bit not set (local)
166 PUSH DS ;FO.;AN001; save ds
167 TEST [Fastopenflg
],Set_For_Search
;FO.;AN001; from fastopen
168 JZ notfast
;FO.;AN001;
169 MOV SI,BX ;FO.;AN001;
170 MOV DS,WORD PTR [CURBUF
+2] ;FO.;AN001;
171 JMP SHORT movmov
;FO.;AN001;
175 MOV SI,OFFSET DOSGROUP
:NAME1
; find_buf 2 = formatted name
179 CMP BYTE PTR ES:[DI-1],5
181 MOV BYTE PTR ES:[DI-1],0E5H
186 POP DS ;FO.;AN001; restore ds
191 PUSH AX ; Save AH device info
196 ; 4 bytes of 21 byte cont structure left for NET stuff
198 POP AX ; Recover AH device info
200 JS DOSREL
; Device entry is DOSGROUP relative
201 CMP WORD PTR [CURBUF
],-1
203 TEST [FastOPenFlg
],Set_For_Search
;AN000;;FO. from fastopen and is good
204 JNZ OKSTORE
;AN000;;FO.
208 ; The user has specified the root directory itself, rather than some
209 ; contents of it. We can't "find" that.
210 MOV WORD PTR ES:[DI-8],-1 ; Cause DOS_SEARCH_NEXT to fail by
211 ; stuffing a -1 at Lastent
215 MOV DS,WORD PTR [CURBUF
+2]
218 MOV SI,BX ; SI-> start of entry
220 ; NOTE: DOS_RENAME depends on BX not being altered after this point
222 MOV CX,SIZE dir_entry
224 MOV AX,DI ; save the 1st byte addr
226 MOV DI,AX ; restore 1st byte addr
227 CMP BYTE PTR ES:[DI],05H ; special char check
229 MOV BYTE PTR ES:[DI],0E5H ; convert it back to E5
233 AND CS:[FastOpenflg
],Fast_yes
;AN000;;FO. reset fastopen
239 EndProc DOS_SEARCH_FIRST
241 BREAK <DOS_SEARCH_NEXT
- scan for subsequent matches
>
244 ; [DMAADD] Points to 53 byte buffer returned by DOS_SEARCH_FIRST
245 ; (only first 21 bytes must have valid information)
247 ; Look for subsequent matches
250 ; The 53 bytes at DMAADD are updated for next call
251 ; (see DOS_SEARCH_FIRST)
254 ; error_no_more_files
255 ; No more files to find
256 ; DS preserved, others destroyed
258 procedure DOS_SEARCH_NEXT
,NEAR
259 DOSAssume
CS,<DS>,"DOS_Search_Next"
264 TEST AL,80H
; Test for NET
267 transfer NET_SEARCH_NEXT
269 MOV AX,(multNET
SHL 8) OR 28
276 MOV [EXTERR_LOCUS
],errLOC_Disk
278 MOV WORD PTR ThisCDS
,OFFSET DOSGROUP
:DummyCDS
279 MOV WORD PTR ThisCDS
+2,CS
283 ; invoke GetThisDrv ; Set CDS pointer
285 JC No_files
; Bogus drive letter
286 LES DI,[THISCDS
] ; Get CDS pointer
287 LES BP,ES:[DI.curdir_devptr
]; Get DPB pointer
288 invoke GOTDPB
; [THISDPB] = ES:BP
290 mov AL,ES:[BP.dpb_drive
]
293 MOV WORD PTR [CREATING
],0E500H
294 MOV [NoSetDir
],1 ; if we find a dir, don't change to it
302 entry RENAME_NEXT
; Entry used by DOS_RENAME
304 context
ES ; THIS BLOWS ES:BP POINTER TO DPB
305 MOV DI,OFFSET DOSGROUP
:NAME1
307 REP MOVSB ; Search name
317 PUSH AX ; Save LastEnt
321 LES BP,[THISDPB
] ; Recover ES:BP
334 XOR AH,AH ; If Search_Next, can't be a DEV
337 EndProc DOS_SEARCH_NEXT
340 ;Input: [WFP_START]= pointer to final path
341 ;Function: check '?' char
342 ;Output: carry clear, if no '?'
343 ; carry set, if '?' exists
345 procedure CHECK_QUESTION
,NEAR ;AN000;
346 ASSUME
ES:NOTHING
,DS:NOTHING
;AN000;
349 POP DS ;AN000;;FO. ds:si -> final path
350 MOV SI,[WFP_START
] ;AN000;;FO.
352 LODSB ;AN000;;FO. get char
353 OR AL,AL ;AN000;;FO. is it null
354 JZ NO_Question
;AN000;;FO. yes
355 CMP AL,'?' ;AN000;;FO. is '?'
356 JNZ getnext
;AN000;;FO. no
361 EndProc CHECK_QUESTION
;AN000;