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

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MAPPER / QFILEINF.ASM
1 ;\ f \e0
2 page 80,132
3 ;
4 title CP/DOS DosQFileInfo mapper
5 ;
6
7 FileAttributeSegment segment word public 'fat'
8
9 extrn FileAttributeTable:word
10
11 FileAttributeSegment ends
12
13 dosxxx segment byte public 'dos'
14 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
15 ;
16 ;**********************************************************************
17 ;*
18 ;* MODULE: dosQfileinfo
19 ;*
20 ;* FILE NAME: dos052.asm
21 ;*
22 ;* CALLING SEQUENCE:
23 ;*
24 ;* push word filehandle
25 ;* push word fileinfolevel
26 ;* push@ other fileinfobuffer
27 ;* push word filebuffersize
28 ;* call dossetfileinfo
29 ;*
30 ;* MODULES CALLED: PC-DOS Int 21h, ah=57h, set file's date/time
31 ;*
32 ;*********************************************************************
33
34 public dosQfileinfo
35 .sall
36 .xlist
37 include macros.inc
38 .list
39
40
41 FileInfo struc
42 CreateDate dw ?
43 CreateTime dw ?
44 LastAccessDate dw ?
45 LastAccessTime dw ?
46 LastWriteDate dw ?
47 LastWriteTime dw ?
48 DataLength dd ? ; File size
49 FileSpace dd ? ; falloc_size
50 Attributes dw ? ; attributes
51 FileInfo ends
52
53
54 str struc
55 old_bp dw ?
56 return dd ?
57 BufferSize dw ? ; file data buffer size
58 BufferPtr dd ? ; file data buffer
59 Level dw ? ; file data info level
60 Handle dw ? ; file handle
61 str ends
62
63 dosQfileinfo proc far
64 Enter dosQfileinfo ; save registers
65
66 mov bx,[bp].handle ;fill registers for function call
67
68 mov ax,05700h
69 int 21h ; get file date and time
70 jc ErrorExit ; jump if error
71
72 lds si,[bp].BufferPtr ; copy date and time to
73 mov ds:[si].CreateDate,dx ; file info return data area
74 mov ds:[si].CreateTime,cx
75 mov ds:[si].LastAccessDate,dx
76 mov ds:[si].LastAccessTime,cx
77 mov ds:[si].LastWriteDate,dx
78 mov ds:[si].LastWriteTime,cx
79
80 ; Calculate the file length and file space and save in the file info data area
81
82 mov cx,0 ; get the current position
83 mov dx,0
84 mov bx,[bp].handle ; get file handle
85
86 mov ax,04201h
87 int 21h ; move file pointer to the
88 jc ErrorExit ; current position
89
90 push dx
91 push ax
92
93 mov cx,0
94 mov dx,0
95 mov bx,[bp].Handle
96
97 mov ax,04202h ; move file pointer to end-of-file
98 int 21h
99
100 lds si,[bp].BufferPtr ; save the file length in
101 mov ds:word ptr DataLength[si+0],ax ; file info data area
102 mov ds:word ptr DataLength[si+2],dx
103
104 test ax,511
105 jz HaveSpace
106
107 and ax,not 511
108 add ax,512
109 adc dx,0
110
111 HaveSpace:
112 mov ds:word ptr FileSpace[si+0],ax ; save file space
113 mov ds:word ptr FileSpace[si+2],dx ; in return data area
114
115 ; calculate the file attribute and save
116
117 pop dx
118 pop cx
119
120 mov bx,[bp].Handle
121
122 mov ax,04200h
123 int 21h ; move the file pointer
124 jc ErrorExit
125
126 mov ax,seg FileAttributeSegment
127 mov ds,ax
128 assume ds:FileAttributeSegment
129
130 mov bx,[bp].Handle
131 add bx,bx
132
133 mov ax,FileAttributeTable[bx]
134 mov [bp].Attributes,ax ; save file attribute
135
136 sub ax,ax ; set good return code
137
138 ErrorExit:
139 mexit ; restore registers
140 ret size str - 6 ; return
141
142 dosqfileinfo endp
143
144 dosxxx ends
145
146 end