Subversion Repositories Kolibri OS

Rev

Rev 2 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 71
Line 1080... Line 1080...
1080
    cmp    eax,0x0
1080
    cmp    eax,0x0
1081
    jnz    check_new_flp
1081
    jnz    check_new_flp
Line 1082... Line 1082...
1082
 
1082
 
1083
   pop ebx
1083
   pop ebx
-
 
1084
   ret
-
 
1085
 
-
 
1086
; \begin{diamond}
-
 
1087
fd_find_lfn:
-
 
1088
; in: esi->name
-
 
1089
; out: CF=1 - file not found
-
 
1090
;      else CF=0 and edi->direntry
-
 
1091
	pusha
-
 
1092
	sub	esp, 262*2	; reserve place for LFN
-
 
1093
	mov	ebp, esp
-
 
1094
	call	read_flp_fat
-
 
1095
	cmp	[FDC_Status], 0
-
 
1096
	jnz	.error
-
 
1097
	mov	eax, 19
-
 
1098
	mov	dh, 14
-
 
1099
.main_loop:
-
 
1100
.20_1:
-
 
1101
	pusha
-
 
1102
	call	read_chs_sector
-
 
1103
	popa
-
 
1104
	cmp	[FDC_Status], 0
-
 
1105
	jnz	.error
-
 
1106
	mov	edi, 0xD000
-
 
1107
	inc	[FDD_Sector]
-
 
1108
	push	eax
-
 
1109
.21_1:
-
 
1110
	call	fat_get_name
-
 
1111
	jc	@f
-
 
1112
	call	fat_compare_name
-
 
1113
	jz	.found
-
 
1114
@@:
-
 
1115
	add	edi, 0x20
-
 
1116
	cmp	edi, 0xD200
-
 
1117
	jb	.21_1
-
 
1118
	pop	eax
-
 
1119
	inc	eax
-
 
1120
	dec	dh
-
 
1121
	js	@f
-
 
1122
	jnz	.20_1
-
 
1123
.error:
-
 
1124
	add	esp, 262*2
-
 
1125
	popa
-
 
1126
	stc
-
 
1127
	ret
-
 
1128
@@:
-
 
1129
; read next sector from FAT
-
 
1130
	mov	eax, [(eax-31)*2+0x282000]
-
 
1131
	and	eax, 0xFFF
-
 
1132
	cmp	eax, 0xFF8
-
 
1133
	jae	.error
-
 
1134
	add	eax, 31
-
 
1135
	jmp	.main_loop
-
 
1136
.found:
-
 
1137
	pop	eax
-
 
1138
; if LFN entry, advance to corresponding short entry
-
 
1139
	cmp	byte [edi+11], 0xF
-
 
1140
	jnz	.entryfound
-
 
1141
	add	edi, 0x20
-
 
1142
	cmp	edi, 0xD200
-
 
1143
	jb	.entryfound
-
 
1144
	dec	dh
-
 
1145
	jz	.error
-
 
1146
	inc	eax
-
 
1147
	call	read_chs_sector
-
 
1148
	cmp	[FDC_Status], 0
-
 
1149
	jnz	.error
-
 
1150
	mov	edi, 0xD000
-
 
1151
.entryfound:
-
 
1152
	cmp	byte [esi], 0
-
 
1153
	jz	.done
-
 
1154
	test	byte [edi+11], 10h	; is a directory?
-
 
1155
	jz	.error
-
 
1156
	movzx	eax, word [edi+26]
-
 
1157
	add	eax, 31
-
 
1158
	mov	dh, 0
-
 
1159
	jmp	.main_loop
-
 
1160
.done:
-
 
1161
	add	esp, 262*2+4
-
 
1162
	push	edi
-
 
1163
	popad
-
 
1164
	ret
-
 
1165
 
-
 
1166
;----------------------------------------------------------------
-
 
1167
;
-
 
1168
;  fs_FloppyRead - LFN variant for reading floppy
-
 
1169
;
-
 
1170
;  esi  points to filename
-
 
1171
;  ebx  pointer to 64-bit number = first wanted byte, 0+
-
 
1172
;       may be ebx=0 - start from first byte
-
 
1173
;  ecx  number of bytes to read, 0+
-
 
1174
;  edx  mem location to return data
-
 
1175
;
-
 
1176
;  ret ebx = size or 0xffffffff file not found
-
 
1177
;      eax = 0 ok read or other = errormsg
-
 
1178
;
-
 
1179
;--------------------------------------------------------------
-
 
1180
fs_FloppyRead:
-
 
1181
	mov	[save_flag], 0
-
 
1182
	cmp	byte [esi], 0
-
 
1183
	jnz	@f
-
 
1184
	or	ebx, -1
-
 
1185
	mov	eax, 10		; access denied
-
 
1186
	ret
-
 
1187
@@:
-
 
1188
	push	edi
-
 
1189
	call	fd_find_lfn
-
 
1190
	jnc	.found
-
 
1191
	pop	edi
-
 
1192
	or	ebx, -1
-
 
1193
	mov	eax, 5		; file not found
-
 
1194
	ret
-
 
1195
.found:
-
 
1196
	test	ebx, ebx
-
 
1197
	jz	.l1
-
 
1198
	cmp	dword [ebx+4], 0
-
 
1199
	jz	@f
-
 
1200
	mov	ebx, [edi+28]
-
 
1201
.reteof:
-
 
1202
	mov	eax, 6		; EOF
-
 
1203
	pop	edi
-
 
1204
	ret
-
 
1205
@@:
-
 
1206
	mov	ebx, [ebx]
-
 
1207
.l1:
-
 
1208
	push	dword [edi+28]
-
 
1209
	push	dword [edi+28]
-
 
1210
	movzx	edi, word [edi+26]
-
 
1211
	push	ecx edx
-
 
1212
.new:
-
 
1213
	jecxz	.done
-
 
1214
	test	edi, edi
-
 
1215
	jz	.eof
-
 
1216
	cmp	edi, 0xFF8
-
 
1217
	jae	.eof
-
 
1218
	mov	eax, edi
-
 
1219
	add	eax, 31
-
 
1220
	pusha
-
 
1221
	call	read_chs_sector
-
 
1222
	popa
-
 
1223
	cmp	[FDC_Status], 0
-
 
1224
	jnz	.err
-
 
1225
	sub	ebx, 512
-
 
1226
	jae	.skip
-
 
1227
	lea	eax, [eax+ebx+512]
-
 
1228
	neg	ebx
-
 
1229
	push	ecx
-
 
1230
	cmp	ecx, ebx
-
 
1231
	jbe	@f
-
 
1232
	mov	ecx, ebx
-
 
1233
@@:
-
 
1234
	cmp	ecx, [esp+12]
-
 
1235
	jbe	@f
-
 
1236
	mov	ecx, [esp+12]
-
 
1237
@@:
-
 
1238
	mov	ebx, edx
-
 
1239
	mov	eax, 0xD000
-
 
1240
	call	memmove
-
 
1241
	add	edx, ecx
-
 
1242
	sub	[esp], ecx
-
 
1243
	sub	[esp+12], ecx
-
 
1244
	pop	ecx
-
 
1245
	xor	ebx, ebx
-
 
1246
	cmp	[esp+8], ebx
-
 
1247
	jnz	.skip
-
 
1248
	jecxz	.done
-
 
1249
	jmp	.eof
-
 
1250
.skip:
-
 
1251
	movzx	edi, word [edi*2+0x282000]
-
 
1252
	jmp	.new
-
 
1253
.done:
-
 
1254
	pop	edx ecx ebx ebx edi
-
 
1255
	xor	eax, eax
-
 
1256
	ret
-
 
1257
.eof:
-
 
1258
	pop	edx ecx ebx ebx
-
 
1259
	jmp	.reteof
-
 
1260
.err:
-
 
1261
	mov	eax, 5	; may be other error code?
-
 
1262
	pop	edx ecx ebx ebx edi
-
 
1263
	ret
1084
   ret
1264
; \end{diamond}