Rev 6471 | Rev 6845 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6471 | Rev 6798 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 6471 $ |
8 | $Revision: 6798 $ |
9 | 9 | ||
10 | ; CD external functions |
10 | ; CD external functions |
11 | ; in: |
11 | ; in: |
Line 295... | Line 295... | ||
295 | ;----------------------------------------------------------------------------- |
295 | ;----------------------------------------------------------------------------- |
296 | fs_CdReadFolder: |
296 | fs_CdReadFolder: |
297 | push edi |
297 | push edi |
298 | call cd_find_lfn |
298 | call cd_find_lfn |
299 | jnc .found |
299 | jnc .found |
300 | - | ||
301 | pop edi |
300 | pop edi |
302 | cmp [DevErrorCode], 0 |
301 | cmp [DevErrorCode], 0 |
303 | jne .noaccess_1 |
302 | jne .noaccess_1 |
304 | - | ||
305 | or ebx, -1 |
303 | or ebx, -1 |
306 | mov eax, ERROR_FILE_NOT_FOUND |
304 | mov eax, ERROR_FILE_NOT_FOUND |
307 | ret |
305 | ret |
308 | ;-------------------------------------- |
- | |
- | 306 | ||
309 | .found: |
307 | .found: |
310 | mov edi, [cd_current_pointer_of_input] |
308 | mov edi, [cd_current_pointer_of_input] |
311 | test byte [edi+25], 10b ; do not allow read directories |
309 | test byte [edi+25], 10b ; do not allow read directories |
312 | jnz .found_dir |
310 | jnz .found_dir |
313 | - | ||
314 | pop edi |
311 | pop edi |
315 | ;-------------------------------------- |
- | |
316 | .noaccess_1: |
312 | .noaccess_1: |
317 | or ebx, -1 |
313 | or ebx, -1 |
318 | mov eax, ERROR_ACCESS_DENIED |
314 | mov eax, ERROR_ACCESS_DENIED |
319 | ret |
315 | ret |
- | 316 | ||
- | 317 | .end_buffer: |
|
- | 318 | pop edx eax |
|
- | 319 | sub eax, 2048 ; directory is over? |
|
- | 320 | ja .read_to_buffer |
|
320 | ;-------------------------------------- |
321 | mov eax, [cd_counter_block] |
- | 322 | mov [edx+8], eax |
|
- | 323 | mov eax, [ebx] |
|
- | 324 | sub [edx+4], eax |
|
- | 325 | xor eax, eax |
|
- | 326 | dec ecx |
|
- | 327 | js @f |
|
- | 328 | mov al, ERROR_END_OF_FILE |
|
- | 329 | @@: |
|
- | 330 | pop ecx edi |
|
- | 331 | mov ebx, [edx+4] |
|
- | 332 | ret |
|
- | 333 | ||
321 | .found_dir: |
334 | .found_dir: |
322 | mov eax, [edi+2] ; eax=cluster |
335 | mov eax, [edi+2] ; eax=cluster |
323 | mov [CDSectorAddress], eax |
336 | mov [CDSectorAddress], eax |
324 | mov eax, [edi+10] ; directory size |
337 | mov eax, [edi+10] ; directory size |
325 | ;-------------------------------------- |
- | |
326 | .doit: |
- | |
327 | ; init header |
- | |
328 | push eax ecx |
338 | push eax ecx |
329 | mov edi, edx |
339 | mov edi, edx |
330 | mov ecx, 32/4 |
340 | mov ecx, 32/4 |
331 | xor eax, eax |
341 | xor eax, eax |
332 | rep stosd |
342 | rep stosd |
333 | pop ecx eax |
343 | pop ecx eax |
334 | mov byte [edx], 1 ; version |
344 | mov byte [edx], 1 ; version |
335 | mov [cd_mem_location], edx |
345 | mov [cd_mem_location], edx |
336 | add [cd_mem_location], 32 |
346 | add [cd_mem_location], 32 |
337 | ;.mainloop: |
- | |
338 | mov [cd_counter_block], dword 0 |
347 | mov [cd_counter_block], dword 0 |
339 | dec dword [CDSectorAddress] |
348 | dec dword [CDSectorAddress] |
340 | push ecx |
349 | push ecx |
341 | ;-------------------------------------- |
- | |
342 | .read_to_buffer: |
350 | .read_to_buffer: |
343 | inc dword [CDSectorAddress] |
351 | inc dword [CDSectorAddress] |
344 | mov [CDDataBuf_pointer], CDDataBuf |
352 | mov [CDDataBuf_pointer], CDDataBuf |
345 | call ReadCDWRetr ; read sector of directory |
353 | call ReadCDWRetr ; read sector of directory |
346 | cmp [DevErrorCode], 0 |
354 | cmp [DevErrorCode], 0 |
347 | jne .noaccess_1 |
355 | jne .noaccess_1 |
348 | - | ||
349 | call .get_names_from_buffer |
- | |
350 | sub eax, 2048 |
- | |
351 | ; directory is over? |
- | |
352 | ja .read_to_buffer |
- | |
353 | - | ||
354 | mov edi, [cd_counter_block] |
- | |
355 | mov [edx+8], edi |
- | |
356 | mov edi, [ebx] |
- | |
357 | sub [edx+4], edi |
- | |
358 | xor eax, eax |
- | |
359 | dec ecx |
- | |
360 | js @f |
- | |
361 | - | ||
362 | mov al, ERROR_END_OF_FILE |
- | |
363 | ;-------------------------------------- |
- | |
364 | @@: |
- | |
365 | pop ecx edi |
- | |
366 | mov ebx, [edx+4] |
- | |
367 | ret |
- | |
368 | ;-------------------------------------- |
- | |
369 | .get_names_from_buffer: |
- | |
370 | mov [cd_current_pointer_of_input_2], CDDataBuf |
356 | mov [cd_current_pointer_of_input_2], CDDataBuf |
371 | push eax esi edi edx |
357 | push eax edx |
372 | ;-------------------------------------- |
- | |
373 | .get_names_from_buffer_1: |
358 | .get_names_from_buffer: |
374 | call cd_get_name |
359 | call cd_get_name |
375 | jc .end_buffer |
360 | jc .end_buffer |
376 | - | ||
377 | inc dword [cd_counter_block] |
361 | inc dword [cd_counter_block] |
378 | mov eax, [cd_counter_block] |
362 | mov eax, [cd_counter_block] |
379 | cmp [ebx], eax |
363 | cmp [ebx], eax |
380 | jae .get_names_from_buffer_1 |
364 | jae .get_names_from_buffer |
381 | - | ||
382 | test ecx, ecx |
365 | test ecx, ecx |
383 | jz .get_names_from_buffer_1 |
366 | jz .get_names_from_buffer |
384 | - | ||
385 | mov edi, [cd_counter_block] |
367 | mov edi, [cd_counter_block] |
386 | mov [edx+4], edi |
368 | mov [edx+4], edi |
387 | dec ecx |
369 | dec ecx |
388 | mov esi, ebp |
370 | mov esi, ebp |
389 | mov edi, [cd_mem_location] |
371 | call cd_get_parameters_of_file |
390 | add edi, 40 |
372 | add edi, 40 |
- | 373 | mov ax, '.' |
|
391 | test dword [ebx+4], 1; 0=ANSI, 1=UNICODE |
374 | cmp dword[ebx+4], 2 |
392 | jnz .unicode |
375 | jz .utf16 |
393 | ;-------------------------------------- |
376 | cmp dword[ebx+4], 3 |
394 | .ansi: |
377 | jz .utf8 |
395 | cmp [cd_counter_block], 2 |
378 | cmp [cd_counter_block], 2 |
396 | jbe .ansi_parent_directory |
379 | jbe .parentDirectory |
397 | 380 | @@: |
|
398 | cld |
- | |
399 | lodsw |
381 | lodsw |
400 | xchg ah, al |
382 | xchg ah, al |
401 | call uni2ansi_char |
383 | call uni2ansi_char |
402 | cld |
- | |
403 | stosb |
384 | stosb |
404 | ; check end of file |
- | |
405 | mov ax, [esi] |
- | |
406 | cmp ax, word 3B00h ; separator end of file ';' |
- | |
407 | je .cd_get_parameters_of_file_1 |
- | |
408 | ; check for files not ending with separator |
- | |
409 | movzx eax, byte [ebp-33] |
- | |
410 | add eax, ebp |
385 | call .checkForEnd |
411 | sub eax, 34 |
- | |
412 | cmp esi, eax |
- | |
413 | je .cd_get_parameters_of_file_1 |
- | |
414 | ; check the end of the directory |
- | |
415 | movzx eax, byte [ebp-1] |
- | |
416 | add eax, ebp |
- | |
417 | cmp esi, eax |
- | |
418 | jb .ansi |
386 | jc @b |
419 | ;-------------------------------------- |
- | |
420 | .cd_get_parameters_of_file_1: |
387 | @@: |
421 | mov [edi], byte 0 |
388 | mov [edi], byte 0 |
422 | call cd_get_parameters_of_file |
- | |
423 | add [cd_mem_location], 304 |
389 | add [cd_mem_location], 304 |
424 | jmp .get_names_from_buffer_1 |
390 | jmp .get_names_from_buffer |
425 | ;-------------------------------------- |
- | |
- | 391 | ||
426 | .ansi_parent_directory: |
392 | .parentDirectory: |
- | 393 | stosb |
|
427 | cmp [cd_counter_block], 2 |
394 | cmp [cd_counter_block], 2 |
428 | je @f |
395 | jnz @b |
- | 396 | stosb |
|
- | 397 | jmp @b |
|
Line 429... | Line -... | ||
429 | - | ||
430 | mov [edi], byte '.' |
- | |
431 | inc edi |
- | |
432 | jmp .cd_get_parameters_of_file_1 |
- | |
433 | ;-------------------------------------- |
398 | |
434 | @@: |
- | |
435 | mov [edi], word '..' |
399 | .utf8: |
436 | add edi, 2 |
- | |
437 | jmp .cd_get_parameters_of_file_1 |
- | |
438 | ;-------------------------------------- |
- | |
439 | .unicode: |
400 | add [cd_mem_location], 256 |
440 | cmp [cd_counter_block], 2 |
401 | cmp [cd_counter_block], 2 |
- | 402 | jbe .parentDirectory |
|
- | 403 | push ecx |
|
- | 404 | mov ecx, 519 |
|
- | 405 | @@: |
|
- | 406 | lodsw |
|
- | 407 | xchg ah, al |
|
- | 408 | call UTF16to8 |
|
- | 409 | js @f |
|
- | 410 | call .checkForEnd |
|
- | 411 | jc @b |
|
- | 412 | @@: |
|
- | 413 | pop ecx |
|
- | 414 | mov [edi], byte 0 |
|
- | 415 | add [cd_mem_location], 304 |
|
Line 441... | Line -... | ||
441 | jbe .unicode_parent_directory |
- | |
442 | - | ||
443 | cld |
416 | jmp .get_names_from_buffer |
444 | movsw |
417 | |
445 | ; check end of file |
418 | .checkForEnd: |
446 | mov ax, [esi] |
419 | mov ax, [esi] |
447 | cmp ax, word 3B00h; separator end of file ';' |
420 | cmp ax, 3B00h ; ';' |
448 | je .cd_get_parameters_of_file_2 |
421 | jz @f |
449 | ; check for files not ending with separator |
422 | ; check for files not ending with separator |
450 | movzx eax, byte [ebp-33] |
423 | movzx eax, byte [ebp-33] |
451 | add eax, ebp |
424 | add eax, ebp |
452 | sub eax, 34 |
425 | sub eax, 34 |
453 | cmp esi, eax |
426 | cmp esi, eax |
454 | je .cd_get_parameters_of_file_2 |
427 | jz @f |
455 | ; check the end of the directory |
428 | ; check the end of the directory |
456 | movzx eax, byte [ebp-1] |
429 | movzx eax, byte [ebp-1] |
- | 430 | add eax, ebp |
|
- | 431 | cmp esi, eax |
|
- | 432 | @@: |
|
- | 433 | ret |
|
457 | add eax, ebp |
434 | |
458 | cmp esi, eax |
435 | .utf16: |
- | 436 | cmp [cd_counter_block], 2 |
|
- | 437 | jbe .utf16ParentDirectory |
|
- | 438 | @@: |
|
- | 439 | lodsw |
|
459 | jb .unicode |
440 | xchg ah, al |
- | 441 | stosw |
|
- | 442 | call .checkForEnd |
|
460 | ;-------------------------------------- |
443 | jc @b |
461 | .cd_get_parameters_of_file_2: |
- | |
462 | mov [edi], word 0 |
444 | @@: |
463 | call cd_get_parameters_of_file |
445 | mov [edi], word 0 |
464 | add [cd_mem_location], 560 |
- | |
- | 446 | add [cd_mem_location], 560 |
|
465 | jmp .get_names_from_buffer_1 |
447 | jmp .get_names_from_buffer |
- | 448 | ||
466 | ;-------------------------------------- |
449 | .utf16ParentDirectory: |
467 | .unicode_parent_directory: |
450 | stosw |
- | 451 | cmp [cd_counter_block], 2 |
|
- | 452 | jnz @b |
|
Line 468... | Line -... | ||
468 | cmp [cd_counter_block], 2 |
- | |
469 | je @f |
- | |
470 | - | ||
471 | mov [edi], word 2E00h; '.' |
- | |
472 | add edi, 2 |
- | |
473 | jmp .cd_get_parameters_of_file_2 |
- | |
474 | ;-------------------------------------- |
- | |
475 | @@: |
- | |
476 | mov [edi], dword 2E002E00h; '..' |
- | |
477 | add edi, 4 |
- | |
478 | jmp .cd_get_parameters_of_file_2 |
- | |
479 | ;-------------------------------------- |
- | |
480 | .end_buffer: |
- | |
481 | pop edx edi esi eax |
453 | stosw |
482 | ret |
454 | jmp @b |
483 | ;----------------------------------------------------------------------------- |
455 | |
484 | cd_get_parameters_of_file: |
456 | cd_get_parameters_of_file: |
485 | mov edi, [cd_mem_location] |
457 | mov edi, [cd_mem_location] |
Line 490... | Line 462... | ||
490 | inc eax |
462 | inc eax |
491 | shl eax, 1 |
463 | shl eax, 1 |
492 | ; is a directory? |
464 | ; is a directory? |
493 | test [ebp-8], byte 2 |
465 | test [ebp-8], byte 2 |
494 | jz .file |
466 | jz .file |
495 | - | ||
496 | inc eax |
467 | inc eax |
497 | ;-------------------------------------- |
- | |
498 | .file: |
468 | .file: |
499 | ; not as a volume label in the FAT, in this form not available |
469 | ; not as a volume label in the FAT, in this form not available |
500 | ; file is not a system |
470 | ; file is not a system |
501 | shl eax, 3 |
471 | shl eax, 3 |
502 | ; file is hidden? (attribute of existence) |
472 | ; file is hidden? (attribute of existence) |
503 | test [ebp-8], byte 1 |
473 | test [ebp-8], byte 1 |
504 | jz .hidden |
474 | jz .hidden |
505 | - | ||
506 | inc eax |
475 | inc eax |
507 | ;-------------------------------------- |
- | |
508 | .hidden: |
476 | .hidden: |
509 | shl eax, 1 |
477 | shl eax, 1 |
510 | ; file is always read-only, as this CD |
478 | ; file is always read-only, as this CD |
511 | inc eax |
479 | inc eax |
512 | mov [edi], eax |
480 | mov [edi], eax |
- | 481 | mov eax, [ebx+4] |
|
- | 482 | mov [edi+4], eax |
|
513 | ; get the time to file |
483 | ; get the time to file |
514 | ; hour |
484 | ; hour |
515 | movzx eax, byte [ebp-12] |
485 | movzx eax, byte [ebp-12] |
516 | shl eax, 8 |
486 | shl eax, 8 |
517 | ; minute |
487 | ; minute |
Line 539... | Line 509... | ||
539 | mov [edi+12], eax |
509 | mov [edi+12], eax |
540 | ; last access date |
510 | ; last access date |
541 | mov [edi+20], eax |
511 | mov [edi+20], eax |
542 | ; last write date |
512 | ; last write date |
543 | mov [edi+28], eax |
513 | mov [edi+28], eax |
544 | ; get the data type of name |
- | |
545 | xor eax, eax |
- | |
546 | test dword [ebx+4], 1; 0=ANSI, 1=UNICODE |
- | |
547 | jnz .unicode_1 |
- | |
548 | - | ||
549 | mov [edi+4], eax |
- | |
550 | jmp @f |
- | |
551 | ;-------------------------------------- |
- | |
552 | .unicode_1: |
- | |
553 | inc eax |
- | |
554 | mov [edi+4], eax |
- | |
555 | ;-------------------------------------- |
- | |
556 | @@: |
- | |
557 | ; get the file size in bytes |
514 | ; get the file size in bytes |
558 | xor eax, eax |
515 | xor eax, eax |
559 | mov [edi+32+4], eax |
516 | mov [edi+32+4], eax |
560 | mov eax, [ebp-23] |
517 | mov eax, [ebp-23] |
561 | mov [edi+32], eax |
518 | mov [edi+32], eax |