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