]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MAPPER/F_NEXT.ASM
4 title CP
/DOS DosFindNext mapper
9 FindSegment
segment word public 'find'
11 extrn SearchCount
:word
12 extrn ReturnBufferSave
:dword
14 extrn ReturnLengthToGo
:word
17 extrn SaveDTAOffset
:word
18 extrn SaveDTASegment
:word
19 extrn SaveDTAFlag
:byte
21 ; We will use the offset into the segment 'FindSegment' as the handle that we
22 ; return and use in subsequent FindNext and FindClose calls. The data that is
23 ; in the word is the offset into the 'FindSegment' to the DTA that we should
28 extrn FindHandles
:word
32 dosxxx
segment byte public 'dos'
33 assume
cs:dosxxx
,ds:nothing
,es:nothing
,ss:nothing
35 ; ************************************************************************* *
37 ; * MODULE: DosFindNext
39 ; * FILE NAME: DOS022.ASM
41 ; * FUNCTION: This module finds the next file in a sequence initiated
42 ; * by the find first the command.
49 ; * PUSH WORD DirHandle ; Directory search handle
50 ; * PUSH@ OTHER ResultBuf ; Result buffer
51 ; * PUSH DWORD ResultBufLen ; Result buffer length
52 ; * PUSH@ WORD SearchCount ; # of entries to find
58 ; * IF ERROR (AX not = 0)
62 ; * o Invalid file path name
64 ; * o Invalid search attribute
66 ; * MODULES CALLED: DOS int 21H function 2FH
67 ; * DOS int 21H function 4FH
69 ; *************************************************************************
83 FindBufferPtr dd ?
;Changed to DW to match the DOSCALL.h PyL 6/1 Rsltbuf21 dd ?
93 mov ax,seg FindSegment
; get address to our data
97 ; check for a valid dir handle
99 ; Special Logic to handle DirHandle = 1
101 mov si,[bp].DirHandle
105 mov si,offset FindSegment
:FindHandles
108 test ds:[si],OpenedHandle
116 ; We have a handle, let's look for the file(s)
119 mov si,ds:[si] ; get the DTA pointer
120 and si,not OpenedHandle
; and get rid of the allocated flag
121 mov CurrentDTA
,si ; and save the current DTA value
123 ; save the callers dta so we can restore it later
128 mov SaveDTASegment
,es
131 ; Set the dta to our area
137 ; Get the count of files to search for
139 les di,[bp].FindCountPtr
; load result buffer pointer
140 mov ax,es:[di] ; save the search
141 mov SearchCount
,ax ; count
142 mov es:word ptr [di],0 ; set found count to zero
144 cmp ax,0 ; just in case they try to trick us!
152 mov ax,[bp].FindBufferLen
; load the buffer length
153 mov ReturnLengthToGo
,ax ; save low order buffer length
155 les di,[bp].FindBufferPtr
; load result buffer pointer
156 mov word ptr ReturnBufferSave
+0,di
157 mov word ptr ReturnBufferSave
+2,es
166 ; Move find data into the return areas
169 sub ReturnLengthToGo
,size FileFindBuf
; check if result buffer is larg enough
170 jnc BufferLengthOk
; it is ok
172 mov ax,8 ; report 'Insufficient memory'
173 jmp ErrorExit
; error return - buffer not large enough
176 mov si,CurrentDTA
; DS:SI -> our dta area
177 les di,ReturnBufferSave
179 ; At this point, the following MUST be true:
180 ; es:di -> where we are to put the resultant data
181 ; ds:si -> DTA from find (either first or next)
183 mov ax,ds:[si].DTAFileDate
184 mov es:[di].Create_Date
,ax
185 mov es:[di].Access_Date
,ax
186 mov es:[di].Write_Date
,ax
188 mov ax,ds:[si].DTAFileTime
189 mov es:[di].Create_Time
,ax
190 mov es:[di].Access_Time
,ax
191 mov es:[di].Write_Time
,ax
193 mov ax,ds:word ptr [si].DTAFileSize
+0
194 mov es:word ptr [di].File_Size
+0,ax
195 mov es:word ptr [di].FAlloc_Size
+0,ax
196 mov ax,ds:word ptr [si].DTAFileSize
+2
197 mov es:word ptr [di].File_Size
+2,ax
198 mov es:word ptr [di].FAlloc_Size
+2,ax
200 test es:word ptr [di].FAlloc_Size
,001ffh
203 and es:word ptr [di].FAlloc_Size
,not 001ffh
204 add es:word ptr [di].FAlloc_Size
,00200h
208 mov al,ds:[si].DTAFileAttrib
209 mov es:[di].Attributes
,ax
215 mov al,ds:[si+bx].DTAFileName
219 mov es:[di+bx].File_Name
,al
224 mov es:[di+bx].File_Name
,0
226 mov es:[di].String_len
,al
229 mov word ptr ReturnBufferSave
+0,di
230 mov word ptr ReturnBufferSave
+2,es
232 les di,[bp].FindCountPtr
236 ; Check if the request was for more than one
244 sub ax,ax ; set good return code
248 mov ax,seg FindSegment
250 assume
ds:FindSegment