]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MAPPER/F_CLOSE.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MAPPER / F_CLOSE.ASM
1 page 80,132
2
3 title CP/DOS DosFindClose mapper
4
5 include find.inc
6
7
8 FindSegment segment word public 'find'
9
10 ; We will use the offset into the segment 'FindSegment' as the handle that we
11 ; return and use in subsequent FindNext and FindClose calls. The data that is
12 ; in the word is the offset into the 'FindSegment' to the DTA that we should
13 ; use.
14 extrn FindDTAs:word
15 extrn FindHandles:word
16
17 FindSegment ends
18
19
20 ; ************************************************************************* *
21 ; *
22 ; * MODULE: DosFindClose
23 ; *
24 ; * FUNCTION: Close Find Handle
25 ; *
26 ; * FUNCTION: This module closes the directory handle used by CP/DOS
27 ; * in a find first/find next search. Since PC/DOS does not
28 ; * use directory handles it will simply return to the caller
29 ; * removing the parameters passed on the stack.
30 ; *
31 ; * CALLING SEQUENCE:
32 ; *
33 ; * PUSH WORD DirHandle ; Directory search handle
34 ; * CALL DosFindClose
35 ; *
36 ; *
37 ; * RETURN SEQUENCE:
38 ; *
39 ; * IF ERROR (AX not = 0)
40 ; *
41 ; * AX = Error Code:
42 ; *
43 ; *
44 ; * MODULES CALLED: None
45 ; *
46 ; *************************************************************************
47
48 public DosFindClose
49 .sall
50 .xlist
51 include macros.inc
52 .list
53
54 str struc
55 old_bp dw ?
56 return dd ?
57 DirHandle dw ? ; dirctory search handle
58 str ends
59
60
61 dosxxx segment byte public 'dos'
62 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
63
64 DosFindClose proc far
65 Enter DosFindClose ; push registers
66
67 mov ax,seg FindSegment ; get address to our data
68 mov ds,ax
69 assume ds:FindSegment
70
71 ; Close the handle
72
73 ; The 'DirHandle' that the mapper returns from FindFirst, is the offset into
74 ; 'FindSegment' of the pointer to the DTA for that Handle. The 08000h bit
75 ; of the pointer is used to indicate that the handle is open. Reset the bit.
76
77 ; Special Logic to handle DirHandle = 1
78
79 mov si,[bp].DirHandle ; get directory hanlde
80 cmp si,1 ; handle = 1??
81 jne CheckForClose ; branch if not
82
83 mov si,offset FindSegment:FindHandles
84
85 CheckForClose:
86 test ds:[si],OpenedHandle ; handle is open ??
87 jnz OkToClose ; go and close if it is open
88
89 mov ax,6 ; else load error code
90 jmp ErrorExit ; return
91
92 OkToClose:
93 and ds:[si],not OpenedHandle ; set close flag
94 xor ax,ax ; set good return code
95
96 ErrorExit:
97 mexit ; pop registers
98 ret size str - 6 ; return
99
100 DosFindClose endp
101
102 dosxxx ends
103
104 end