Subversion Repositories Kolibri OS

Rev

Rev 6876 | Rev 9692 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
  4. ;;  Distributed under terms of the GNU General Public License.  ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 6880 $
  9.  
  10. ; CD external functions
  11. ;   in:
  12. ; esi -> path string in UTF-8
  13. ; ebx -> parameter structure +4
  14. ; ecx = bytes to read
  15. ; edx -> buffer
  16. ;   out:
  17. ; eax, ebx = return values for sysfunc 70
  18. iglobal
  19. align 4
  20. fs_CdServices:
  21.         dd      fs_CdRead
  22.         dd      fs_CdReadFolder
  23.         dd      fs_NotImplemented
  24.         dd      fs_NotImplemented
  25.         dd      fs_NotImplemented
  26.         dd      fs_CdGetFileInfo
  27.         dd      fs_NotImplemented
  28.         dd      0
  29.         dd      fs_NotImplemented
  30.         dd      fs_NotImplemented
  31. fs_NumCdServices = ($ - fs_CdServices)/4
  32. endg
  33.  
  34. uglobal
  35. align 4
  36. cd_current_pointer_of_input     dd  0
  37. cd_current_pointer_of_input_2   dd  0
  38. cd_mem_location                 dd  0
  39. cd_counter_block                dd  0
  40. cd_status                       dd  0
  41. endg
  42.  
  43. ;-----------------------------------------------------------------------------
  44. fs_NotImplemented:
  45.         movi    eax, ERROR_UNSUPPORTED_FS
  46.         ret
  47. ;-----------------------------------------------------------------------------
  48. reserve_cd:
  49.         cli
  50.         cmp     [cd_status], 0
  51.         je      reserve_ok2
  52.  
  53.         sti
  54.         call    change_task
  55.         jmp     reserve_cd
  56. ;-----------------------------------------------------------------------------
  57. reserve_ok2:
  58.         push    eax
  59.         mov     eax, [CURRENT_TASK]
  60.         shl     eax, 5
  61.         mov     eax, [eax+CURRENT_TASK+TASKDATA.pid]
  62.         mov     [cd_status], eax
  63.         pop     eax
  64.         sti
  65.         ret
  66. ;-----------------------------------------------------------------------------
  67. reserve_cd_channel:
  68.         pushad
  69.         mov     eax, [cdpos]
  70.         dec     eax
  71.         shr     eax, 2
  72.  
  73.         test    eax, eax
  74.         jnz     .1
  75.  
  76.         cmp     [ChannelNumber], 1
  77.         jne     @f
  78.  
  79.         mov     ecx, ide_channel1_mutex
  80.         jmp     .mutex_lock
  81. ;--------------------------------------
  82. @@:
  83.         mov     ecx, ide_channel2_mutex
  84.         jmp     .mutex_lock
  85. ;--------------------------------------
  86. .1:
  87.         dec     eax
  88.         jnz     .2
  89.  
  90.         cmp     [ChannelNumber], 1
  91.         jne     @f
  92.  
  93.         mov     ecx, ide_channel3_mutex
  94.         jmp     .mutex_lock
  95. ;--------------------------------------
  96. @@:
  97.         mov     ecx, ide_channel4_mutex
  98.         jmp     .mutex_lock
  99. ;--------------------------------------
  100. .2:
  101.         cmp     [ChannelNumber], 1
  102.         jne     @f
  103.  
  104.         mov     ecx, ide_channel5_mutex
  105.         jmp     .mutex_lock
  106. ;--------------------------------------
  107. @@:
  108.         mov     ecx, ide_channel6_mutex
  109. .mutex_lock:
  110.         call    mutex_lock
  111.         popad
  112.         ret
  113. ;-----------------------------------------------------------------------------
  114. free_cd_channel:
  115.         pushad
  116.         mov     eax, [cdpos]
  117.         dec     eax
  118.         shr     eax, 2
  119.  
  120.         test    eax, eax
  121.         jnz     .1
  122.  
  123.         cmp     [ChannelNumber], 1
  124.         jne     @f
  125.  
  126.         mov     ecx, ide_channel1_mutex
  127.         jmp     .mutex_unlock
  128. ;--------------------------------------
  129. @@:
  130.         mov     ecx, ide_channel2_mutex
  131.         jmp     .mutex_unlock
  132. ;--------------------------------------
  133. .1:
  134.         dec     eax
  135.         jnz     .2
  136.  
  137.         cmp     [ChannelNumber], 1
  138.         jne     @f
  139.  
  140.         mov     ecx, ide_channel3_mutex
  141.         jmp     .mutex_unlock
  142. ;--------------------------------------
  143. @@:
  144.         mov     ecx, ide_channel4_mutex
  145.         jmp     .mutex_unlock
  146. ;--------------------------------------
  147. .2:
  148.         cmp     [ChannelNumber], 1
  149.         jne     @f
  150.  
  151.         mov     ecx, ide_channel5_mutex
  152.         jmp     .mutex_unlock
  153. ;--------------------------------------
  154. @@:
  155.         mov     ecx, ide_channel6_mutex
  156. .mutex_unlock:
  157.         call    mutex_unlock
  158.         popad
  159.         ret
  160.  
  161. ;-----------------------------------------------------------------------------
  162. fs_CdRead:
  163.         call    cd_find_lfn
  164.         jc      .notFound
  165.         mov     edi, [cd_current_pointer_of_input]
  166.         test    byte [edi+25], 10b  ; do not allow read directories
  167.         jnz     .noaccess
  168.         test    ebx, ebx
  169.         jz      .l1
  170.         cmp     dword [ebx+4], 0
  171.         jz      @f
  172.         xor     ebx, ebx
  173.         movi    eax, ERROR_END_OF_FILE
  174.         ret
  175.  
  176. .notFound:
  177.         cmp     [DevErrorCode], 0
  178.         jne     .noaccess
  179.         xor     ebx, ebx
  180.         movi    eax, ERROR_FILE_NOT_FOUND
  181.         ret
  182.  
  183. .noaccess_3:
  184.         pop     eax edx ecx
  185. .noaccess:
  186.         xor     ebx, ebx
  187.         movi    eax, ERROR_ACCESS_DENIED
  188.         ret
  189.  
  190. @@:
  191.         mov     ebx, [ebx]
  192. .l1:
  193.         push    ecx edx 0
  194.         mov     eax, [edi+10]   ; real size of the file section
  195.         sub     eax, ebx
  196.         jb      .eof
  197.         cmp     eax, ecx
  198.         jae     @f
  199.         mov     ecx, eax
  200.         pop     eax
  201.         push    ERROR_END_OF_FILE
  202. @@:
  203.         mov     eax, [edi+2]
  204.         mov     [CDSectorAddress], eax
  205. ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
  206. .new_sector:
  207.         test    ecx, ecx
  208.         jz      .done
  209.         sub     ebx, 2048
  210.         jae     .next
  211.         add     ebx, 2048
  212.         jnz     .incomplete_sector
  213.         cmp     ecx, 2048
  214.         jb      .incomplete_sector
  215. ; we may read and memmove complete sector
  216.         mov     [CDDataBuf_pointer], edx
  217.         call    ReadCDWRetr
  218.         cmp     [DevErrorCode], 0
  219.         jne     .noaccess_3
  220.         add     edx, 2048
  221.         sub     ecx, 2048
  222. .next:
  223.         inc     dword [CDSectorAddress]
  224.         jmp     .new_sector
  225.  
  226. .eof:
  227.         pop     eax
  228.         push    ERROR_END_OF_FILE
  229. .done:
  230.         mov     ebx, edx
  231.         pop     eax edx ecx
  232.         sub     ebx, edx
  233.         ret
  234.  
  235. .incomplete_sector: ; we must read and memmove incomplete sector
  236.         mov     [CDDataBuf_pointer], CDDataBuf
  237.         call    ReadCDWRetr
  238.         cmp     [DevErrorCode], 0
  239.         jne     .noaccess_3
  240.         push    ecx
  241.         add     ecx, ebx
  242.         cmp     ecx, 2048
  243.         jbe     @f
  244.         mov     ecx, 2048
  245. @@:
  246.         sub     ecx, ebx
  247.         push    edi esi ecx
  248.         mov     edi, edx
  249.         lea     esi, [CDDataBuf + ebx]
  250.         cld
  251.         rep movsb
  252.         pop     ecx esi edi
  253.         add     edx, ecx
  254.         sub     [esp], ecx
  255.         pop     ecx
  256.         xor     ebx, ebx
  257.         jmp     .next
  258.  
  259. ;-----------------------------------------------------------------------------
  260. fs_CdReadFolder:
  261.         push    edi
  262.         call    cd_find_lfn
  263.         jnc     .found
  264.         pop     edi
  265.         cmp     [DevErrorCode], 0
  266.         jne     .noaccess_1
  267.         xor     ebx, ebx
  268.         mov     eax, ERROR_FILE_NOT_FOUND
  269.         ret
  270.  
  271. .found:
  272.         mov     edi, [cd_current_pointer_of_input]
  273.         test    byte [edi+25], 10b    ; do not allow read directories
  274.         jnz     .found_dir
  275.         pop     edi
  276. .noaccess_1:
  277.         xor     ebx, ebx
  278.         mov     eax, ERROR_ACCESS_DENIED
  279.         ret
  280.  
  281. .end_buffer:
  282.         pop     edx eax
  283.         sub     eax, 2048   ; directory is over?
  284.         ja      .read_to_buffer
  285.         mov     eax, [cd_counter_block]
  286.         mov     [edx+8], eax
  287.         mov     eax, [ebx]
  288.         sub     [edx+4], eax
  289.         xor     eax, eax
  290.         dec     ecx
  291.         js      @f
  292.         mov     al, ERROR_END_OF_FILE
  293. @@:
  294.         pop     ecx edi
  295.         mov     ebx, [edx+4]
  296.         ret
  297.  
  298. .found_dir:
  299.         mov     eax, [edi+2]    ; eax=cluster
  300.         mov     [CDSectorAddress], eax
  301.         mov     eax, [edi+10]   ; directory size
  302.         push    eax ecx
  303.         mov     edi, edx
  304.         mov     ecx, 32/4
  305.         xor     eax, eax
  306.         rep stosd
  307.         pop     ecx eax
  308.         mov     byte [edx], 1   ; version
  309.         mov     [cd_mem_location], edx
  310.         add     [cd_mem_location], 32
  311.         mov     [cd_counter_block], dword 0
  312.         dec     dword [CDSectorAddress]
  313.         push    ecx
  314. .read_to_buffer:
  315.         inc     dword [CDSectorAddress]
  316.         mov     [CDDataBuf_pointer], CDDataBuf
  317.         call    ReadCDWRetr     ; read sector of directory
  318.         cmp     [DevErrorCode], 0
  319.         jne     .noaccess_1
  320.         mov     [cd_current_pointer_of_input_2], CDDataBuf
  321.         push    eax edx
  322. .get_names_from_buffer:
  323.         call    cd_get_name
  324.         jc      .end_buffer
  325.         inc     dword [cd_counter_block]
  326.         mov     eax, [cd_counter_block]
  327.         cmp     [ebx], eax
  328.         jae     .get_names_from_buffer
  329.         test    ecx, ecx
  330.         jz      .get_names_from_buffer
  331.         mov     edi, [cd_counter_block]
  332.         mov     [edx+4], edi
  333.         dec     ecx
  334.         mov     esi, ebp
  335.         call    cd_get_parameters_of_file
  336.         add     edi, 40
  337.         mov     ax, '.'
  338.         cmp     dword[ebx+4], 2
  339.         jz      .utf16
  340.         cmp     dword[ebx+4], 3
  341.         jz      .utf8
  342.         cmp     [cd_counter_block], 2
  343.         jbe     .parentDirectory
  344. @@:
  345.         lodsw
  346.         xchg    ah, al
  347.         call    uni2ansi_char
  348.         stosb
  349.         call    .checkForEnd
  350.         jc      @b
  351. @@:
  352.         mov     [edi], byte 0
  353.         add     [cd_mem_location], 304
  354.         jmp     .get_names_from_buffer
  355.  
  356. .parentDirectory:
  357.         stosb
  358.         cmp     [cd_counter_block], 2
  359.         jnz     @b
  360.         stosb
  361.         jmp     @b
  362.  
  363. .utf8:
  364.         add     [cd_mem_location], 256
  365.         cmp     [cd_counter_block], 2
  366.         jbe     .parentDirectory
  367.         push    ecx
  368.         mov     ecx, 519
  369. @@:
  370.         lodsw
  371.         xchg    ah, al
  372.         call    UTF16to8
  373.         js      @f
  374.         call    .checkForEnd
  375.         jc      @b
  376. @@:
  377.         pop     ecx
  378.         mov     [edi], byte 0
  379.         add     [cd_mem_location], 304
  380.         jmp     .get_names_from_buffer
  381.  
  382. .checkForEnd:
  383.         mov     ax, [esi]
  384.         cmp     ax, 3B00h   ; ';'
  385.         jz      @f
  386. ; check for files not ending with separator
  387.         movzx   eax, byte [ebp-33]
  388.         add     eax, ebp
  389.         sub     eax, 34
  390.         cmp     esi, eax
  391.         jz      @f
  392. ; check the end of the directory
  393.         movzx   eax, byte [ebp-1]
  394.         add     eax, ebp
  395.         cmp     esi, eax
  396. @@:
  397.         ret
  398.  
  399. .utf16:
  400.         cmp     [cd_counter_block], 2
  401.         jbe     .utf16ParentDirectory
  402. @@:
  403.         lodsw
  404.         xchg    ah, al
  405.         stosw
  406.         call    .checkForEnd
  407.         jc      @b
  408. @@:
  409.         mov     [edi], word 0
  410.         add     [cd_mem_location], 560
  411.         jmp     .get_names_from_buffer
  412.  
  413. .utf16ParentDirectory:
  414.         stosw
  415.         cmp     [cd_counter_block], 2
  416.         jnz     @b
  417.         stosw
  418.         jmp     @b
  419.  
  420. cd_get_parameters_of_file:
  421.         mov     edi, [cd_mem_location]
  422. cd_get_parameters_of_file_1:
  423. ; get file attributes
  424.         xor     eax, eax
  425. ; file is not archived
  426.         inc     eax
  427.         shl     eax, 1
  428. ; is a directory?
  429.         test    [ebp-8], byte 2
  430.         jz      .file
  431.         inc     eax
  432. .file:
  433. ; not as a volume label in the FAT, in this form not available
  434. ; file is not a system
  435.         shl     eax, 3
  436. ; file is hidden? (attribute of existence)
  437.         test    [ebp-8], byte 1
  438.         jz      .hidden
  439.         inc     eax
  440. .hidden:
  441.         shl     eax, 1
  442. ; file is always read-only, as this CD
  443.         inc     eax
  444.         mov     [edi], eax
  445.         mov     eax, [ebx+4]
  446.         mov     [edi+4], eax
  447. ; get the time to file
  448. ; hour
  449.         movzx   eax, byte [ebp-12]
  450.         shl     eax, 8
  451. ; minute
  452.         mov     al, [ebp-11]
  453.         shl     eax, 8
  454. ; second
  455.         mov     al, [ebp-10]
  456. ; file creation time
  457.         mov     [edi+8], eax
  458. ; last access time
  459.         mov     [edi+16], eax
  460. ; last write time
  461.         mov     [edi+24], eax
  462. ; get date for file
  463. ; year
  464.         movzx   eax, byte [ebp-15]
  465.         add     eax, 1900
  466.         shl     eax, 8
  467. ; month
  468.         mov     al, [ebp-14]
  469.         shl     eax, 8
  470. ; day
  471.         mov     al, [ebp-13]
  472. ; file creation date
  473.         mov     [edi+12], eax
  474. ; last access date
  475.         mov     [edi+20], eax
  476. ; last write date
  477.         mov     [edi+28], eax
  478. ; get the file size in bytes
  479.         xor     eax, eax
  480.         mov     [edi+32+4], eax
  481.         mov     eax, [ebp-23]
  482.         mov     [edi+32], eax
  483.         ret
  484.  
  485. ;-----------------------------------------------------------------------------
  486. fs_CdGetFileInfo:
  487.         call    cd_find_lfn
  488.         movi    eax, ERROR_FILE_NOT_FOUND
  489.         jc      @f
  490.         mov     edi, edx
  491.         mov     eax, [ebx+4]
  492.         mov     [edx+4], eax
  493.         cmp     byte [esi], 0
  494.         jz      .volume
  495.         mov     ebp, [cd_current_pointer_of_input]
  496.         add     ebp, 33
  497.         call    cd_get_parameters_of_file_1
  498.         xor     eax, eax
  499. @@:
  500.         ret
  501.  
  502. .volume:
  503.         test    eax, eax
  504.         jz      .size
  505.         mov     ecx, 16
  506.         mov     esi, CDDataBuf+40
  507.         add     edi, 40
  508.         cmp     eax, 2
  509.         jz      .utf16
  510.         cmp     eax, 3
  511.         jz      .utf8
  512. @@:
  513.         lodsw
  514.         xchg    al, ah
  515.         call    uni2ansi_char
  516.         stosb
  517.         loop    @b
  518.         jmp     .size
  519.  
  520. .utf16:
  521.         lodsw
  522.         xchg    al, ah
  523.         stosw
  524.         loop    .utf16
  525.         jmp     .size
  526.  
  527. .utf8:
  528.         mov     ebx, ecx
  529.         shl     ecx, 1
  530. @@:
  531.         lodsw
  532.         xchg    ah, al
  533.         call    UTF16to8
  534.         dec     ebx
  535.         jnz     @b
  536. .size:
  537.         mov     eax, [CDDataBuf+80]
  538.         shl     eax, 11
  539.         mov     [edx+32], eax
  540.         xor     eax, eax
  541.         mov     [edx+36], eax
  542.         stosw
  543.         mov     byte [edx], 8
  544.         ret
  545.  
  546. ;-----------------------------------------------------------------------------
  547. cd_find_lfn:
  548.         mov     [cd_appl_data], 0
  549. ; in: esi -> path string in UTF-8
  550. ; out: [cd_current_pointer_of_input] -> direntry, CF=1 -> file not found
  551.         push    eax esi
  552. ; Sector 16 - start set of volume descriptors
  553.         call    WaitUnitReady
  554.         cmp     [DevErrorCode], 0
  555.         jne     .access_denied
  556.  
  557.         call    prevent_medium_removal
  558. ; testing of reading
  559.         mov     [CDSectorAddress], dword 16
  560.         mov     [CDDataBuf_pointer], CDDataBuf
  561.         call    ReadCDWRetr;_1
  562.         cmp     [DevErrorCode], 0
  563.         jne     .access_denied
  564.  
  565. ; calculation of the last session
  566.         call    WaitUnitReady
  567.         cmp     [DevErrorCode], 0
  568.         jne     .access_denied
  569.  
  570.         call    Read_TOC
  571.         mov     ah, [CDDataBuf+4+4]
  572.         mov     al, [CDDataBuf+4+5]
  573.         shl     eax, 16
  574.         mov     ah, [CDDataBuf+4+6]
  575.         mov     al, [CDDataBuf+4+7]
  576.         add     eax, 15
  577.         mov     [CDSectorAddress], eax
  578. ;  mov  [CDSectorAddress],dword 15
  579.         mov     [CDDataBuf_pointer], CDDataBuf
  580. ;--------------------------------------
  581. .start:
  582.         inc     dword [CDSectorAddress]
  583.         call    ReadCDWRetr;_1
  584.         cmp     [DevErrorCode], 0
  585.         jne     .access_denied
  586.  
  587. .start_check:
  588. ; checking for "lice"
  589.         cmp     [CDDataBuf+1], dword 'CD00'
  590.         jne     .access_denied
  591.  
  592.         cmp     [CDDataBuf+5], byte '1'
  593.         jne     .access_denied
  594. ; sector is the terminator of set of descriptors volumes?
  595.         cmp     [CDDataBuf], byte 0xff
  596.         je      .access_denied
  597. ; sector is an additional and improved descriptor of volume?
  598.         cmp     [CDDataBuf], byte 0x2
  599.         jne     .start
  600. ; sector is an additional descriptor of volume?
  601.         cmp     [CDDataBuf+6], byte 0x1
  602.         jne     .start
  603.  
  604. ; parameters of root directory
  605.         mov     eax, [CDDataBuf+0x9c+2]; start of root directory
  606.         mov     [CDSectorAddress], eax
  607.         mov     eax, [CDDataBuf+0x9c+10]; size of root directory
  608.         cmp     byte [esi], 0
  609.         jnz     @f
  610.  
  611.         mov     [cd_current_pointer_of_input], CDDataBuf+0x9c
  612.         jmp     .done
  613. ;--------------------------------------
  614. @@:
  615. ; start the search
  616. .mainloop:
  617.         dec     dword [CDSectorAddress]
  618. ;--------------------------------------
  619. .read_to_buffer:
  620.         inc     dword [CDSectorAddress]
  621.         mov     [CDDataBuf_pointer], CDDataBuf
  622.         call    ReadCDWRetr      ; read sector of directory
  623.         cmp     [DevErrorCode], 0
  624.         jne     .access_denied
  625.         call    cd_find_name_in_buffer
  626.         jnc     .found
  627.         sub     eax, 2048
  628. ; directory is over?
  629.         cmp     eax, 0
  630.         ja      .read_to_buffer
  631. ; desired element of chain is not found
  632. .access_denied:
  633.         pop     esi eax
  634.         mov     [cd_appl_data], 1
  635.         stc
  636.         ret
  637. ;--------------------------------------
  638. ; desired element of chain found
  639. .found:
  640. ; the end of the file path
  641.         cmp     byte [esi-1], 0
  642.         jz      .done
  643.         mov     eax, [cd_current_pointer_of_input]
  644.         push    dword [eax+2]
  645.         pop     dword [CDSectorAddress] ; beginning of the directory
  646.         mov     eax, [eax+2+8] ; size of directory
  647.         jmp     .mainloop
  648. ;--------------------------------------
  649. ; file pointer found
  650. .done:
  651.         pop     esi eax
  652.         mov     [cd_appl_data], 1
  653.         clc
  654.         ret
  655. ;-----------------------------------------------------------------------------
  656. cd_find_name_in_buffer:
  657.         mov     [cd_current_pointer_of_input_2], CDDataBuf
  658. ;--------------------------------------
  659. .start:
  660.         call    cd_get_name
  661.         jc      .not_found
  662.  
  663.         call    cd_compare_name
  664.         jc      .start
  665. ;--------------------------------------
  666. .found:
  667.         clc
  668.         ret
  669. ;--------------------------------------
  670. .not_found:
  671.         stc
  672.         ret
  673. ;-----------------------------------------------------------------------------
  674. cd_get_name:
  675.         push    eax
  676.         mov     ebp, [cd_current_pointer_of_input_2]
  677.         mov     [cd_current_pointer_of_input], ebp
  678.         mov     eax, [ebp]
  679.         test    eax, eax ; entry's is over?
  680.         jz      .next_sector
  681.  
  682.         cmp     ebp, CDDataBuf+2048  ; buffer is over?
  683.         jae     .next_sector
  684.  
  685.         movzx   eax, byte [ebp]
  686.         add     [cd_current_pointer_of_input_2], eax ; next entry of directory
  687.         add     ebp, 33; pointer is set to the beginning of the name
  688.         pop     eax
  689.         clc
  690.         ret
  691. ;--------------------------------------
  692. .next_sector:
  693.         pop     eax
  694.         stc
  695.         ret
  696. ;-----------------------------------------------------------------------------
  697. cd_compare_name:
  698. ; in: esi -> UTF-8 name, ebp -> UTF-16BE name
  699. ; out: CF=0 -> names match, esi -> next component of name
  700. ;      CF=1 -> esi is not changed
  701.         push    edx edi eax esi
  702.         mov     edi, ebp
  703. .loop:
  704.         call    utf8to16
  705.         call    utf16toUpper
  706.         mov     edx, eax
  707.         mov     ax, [edi]
  708.         xchg    al, ah
  709.         call    utf16toUpper
  710.         cmp     ax, dx
  711.         jne     .name_not_coincide
  712.         add     edi, 2
  713.         cmp     [esi], byte '/' ; path separator is end of current element
  714.         je      .done
  715.         cmp     [esi], byte 0 ; path separator end of name
  716.         jne     .loop
  717. .done:
  718. ; check end of file
  719.         cmp     [edi], word 3B00h; separator end of file ';'
  720.         je      .done_1
  721. ; check for files not ending with separator
  722.         movzx   eax, byte [ebp-33]
  723.         add     eax, ebp
  724.         sub     eax, 34
  725.         cmp     edi, eax
  726.         je      .done_1
  727. ; check the end of directory
  728.         movzx   eax, byte [ebp-1]
  729.         add     eax, ebp
  730.         cmp     edi, eax
  731.         jne     .name_not_coincide
  732. .done_1:
  733.         pop     eax eax edi edx
  734.         inc     esi
  735.         ret
  736.  
  737. .name_not_coincide:
  738.         pop     esi eax edi edx
  739.         stc
  740.         ret
  741.