Subversion Repositories Kolibri OS

Rev

Rev 6471 | Rev 6872 | 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: 6798 $
  9.  
  10. ; CD external functions
  11. ;   in:
  12. ; esi -> path string in UTF-8
  13. ; ebx -> offset in file (qword)
  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.         push    edi
  164.         cmp     byte [esi], 0
  165.         jnz     @f
  166. ;--------------------------------------
  167. .noaccess:
  168.         pop     edi
  169. ;--------------------------------------
  170. .noaccess_2:
  171.         or      ebx, -1
  172.         mov     eax, ERROR_ACCESS_DENIED
  173.         ret
  174. ;--------------------------------------
  175. .noaccess_3:
  176.         pop     eax edx ecx edi
  177.         jmp     .noaccess_2
  178. ;--------------------------------------
  179. @@:
  180.         call    cd_find_lfn
  181.         jnc     .found
  182.  
  183.         pop     edi
  184.         cmp     [DevErrorCode], 0
  185.         jne     .noaccess_2
  186.  
  187.         or      ebx, -1
  188.         mov     eax, ERROR_FILE_NOT_FOUND
  189.         ret
  190. ;--------------------------------------
  191. .found:
  192.         mov     edi, [cd_current_pointer_of_input]
  193.         test    byte [edi+25], 10b; do not allow read directories
  194.         jnz     .noaccess
  195.  
  196.         test    ebx, ebx
  197.         jz      .l1
  198.  
  199.         cmp     dword [ebx+4], 0
  200.         jz      @f
  201.  
  202.         xor     ebx, ebx
  203. ;--------------------------------------
  204. .reteof:
  205.         mov     eax, 6; end of file
  206.         pop     edi
  207.         ret
  208. ;--------------------------------------
  209. @@:
  210.         mov     ebx, [ebx]
  211. ;--------------------------------------
  212. .l1:
  213.         push    ecx edx
  214.         push    0
  215.         mov     eax, [edi+10] ; real size of the file section
  216.         sub     eax, ebx
  217.         jb      .eof
  218.  
  219.         cmp     eax, ecx
  220.         jae     @f
  221.  
  222.         mov     ecx, eax
  223.         mov     byte [esp], 6
  224. ;--------------------------------------
  225. @@:
  226.         mov     eax, [edi+2]
  227.         mov     [CDSectorAddress], eax
  228. ;--------------------------------------
  229. ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
  230. .new_sector:
  231.         test    ecx, ecx
  232.         jz      .done
  233.  
  234.         sub     ebx, 2048
  235.         jae     .next
  236.  
  237.         add     ebx, 2048
  238.         jnz     .incomplete_sector
  239.  
  240.         cmp     ecx, 2048
  241.         jb      .incomplete_sector
  242. ; we may read and memmove complete sector
  243.         mov     [CDDataBuf_pointer], edx
  244.         call    ReadCDWRetr ; read sector of file
  245.         cmp     [DevErrorCode], 0
  246.         jne     .noaccess_3
  247.  
  248.         add     edx, 2048
  249.         sub     ecx, 2048
  250. ;--------------------------------------
  251. .next:
  252.         inc     dword [CDSectorAddress]
  253.         jmp     .new_sector
  254. ;--------------------------------------
  255. .incomplete_sector:
  256. ; we must read and memmove incomplete sector
  257.         mov     [CDDataBuf_pointer], CDDataBuf
  258.         call    ReadCDWRetr ; read sector of file
  259.         cmp     [DevErrorCode], 0
  260.         jne     .noaccess_3
  261.  
  262.         push    ecx
  263.         add     ecx, ebx
  264.         cmp     ecx, 2048
  265.         jbe     @f
  266.  
  267.         mov     ecx, 2048
  268. ;--------------------------------------
  269. @@:
  270.         sub     ecx, ebx
  271.         push    edi esi ecx
  272.         mov     edi, edx
  273.         lea     esi, [CDDataBuf + ebx]
  274.         cld
  275.         rep movsb
  276.         pop     ecx esi edi
  277.         add     edx, ecx
  278.         sub     [esp], ecx
  279.         pop     ecx
  280.         xor     ebx, ebx
  281.         jmp     .next
  282. ;--------------------------------------
  283. .done:
  284.         mov     ebx, edx
  285.         pop     eax edx ecx edi
  286.         sub     ebx, edx
  287.         ret
  288. ;--------------------------------------
  289. .eof:
  290.         mov     ebx, edx
  291.         pop     eax edx ecx
  292.         sub     ebx, edx
  293.         jmp     .reteof
  294.  
  295. ;-----------------------------------------------------------------------------
  296. fs_CdReadFolder:
  297.         push    edi
  298.         call    cd_find_lfn
  299.         jnc     .found
  300.         pop     edi
  301.         cmp     [DevErrorCode], 0
  302.         jne     .noaccess_1
  303.         or      ebx, -1
  304.         mov     eax, ERROR_FILE_NOT_FOUND
  305.         ret
  306.  
  307. .found:
  308.         mov     edi, [cd_current_pointer_of_input]
  309.         test    byte [edi+25], 10b    ; do not allow read directories
  310.         jnz     .found_dir
  311.         pop     edi
  312. .noaccess_1:
  313.         or      ebx, -1
  314.         mov     eax, ERROR_ACCESS_DENIED
  315.         ret
  316.  
  317. .end_buffer:
  318.         pop     edx eax
  319.         sub     eax, 2048   ; directory is over?
  320.         ja      .read_to_buffer
  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.  
  334. .found_dir:
  335.         mov     eax, [edi+2]    ; eax=cluster
  336.         mov     [CDSectorAddress], eax
  337.         mov     eax, [edi+10]   ; directory size
  338.         push    eax ecx
  339.         mov     edi, edx
  340.         mov     ecx, 32/4
  341.         xor     eax, eax
  342.         rep stosd
  343.         pop     ecx eax
  344.         mov     byte [edx], 1   ; version
  345.         mov     [cd_mem_location], edx
  346.         add     [cd_mem_location], 32
  347.         mov     [cd_counter_block], dword 0
  348.         dec     dword [CDSectorAddress]
  349.         push    ecx
  350. .read_to_buffer:
  351.         inc     dword [CDSectorAddress]
  352.         mov     [CDDataBuf_pointer], CDDataBuf
  353.         call    ReadCDWRetr     ; read sector of directory
  354.         cmp     [DevErrorCode], 0
  355.         jne     .noaccess_1
  356.         mov     [cd_current_pointer_of_input_2], CDDataBuf
  357.         push    eax edx
  358. .get_names_from_buffer:
  359.         call    cd_get_name
  360.         jc      .end_buffer
  361.         inc     dword [cd_counter_block]
  362.         mov     eax, [cd_counter_block]
  363.         cmp     [ebx], eax
  364.         jae     .get_names_from_buffer
  365.         test    ecx, ecx
  366.         jz      .get_names_from_buffer
  367.         mov     edi, [cd_counter_block]
  368.         mov     [edx+4], edi
  369.         dec     ecx
  370.         mov     esi, ebp
  371.         call    cd_get_parameters_of_file
  372.         add     edi, 40
  373.         mov     ax, '.'
  374.         cmp     dword[ebx+4], 2
  375.         jz      .utf16
  376.         cmp     dword[ebx+4], 3
  377.         jz      .utf8
  378.         cmp     [cd_counter_block], 2
  379.         jbe     .parentDirectory
  380. @@:
  381.         lodsw
  382.         xchg    ah, al
  383.         call    uni2ansi_char
  384.         stosb
  385.         call    .checkForEnd
  386.         jc      @b
  387. @@:
  388.         mov     [edi], byte 0
  389.         add     [cd_mem_location], 304
  390.         jmp     .get_names_from_buffer
  391.  
  392. .parentDirectory:
  393.         stosb
  394.         cmp     [cd_counter_block], 2
  395.         jnz     @b
  396.         stosb
  397.         jmp     @b
  398.  
  399. .utf8:
  400.         add     [cd_mem_location], 256
  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
  416.         jmp     .get_names_from_buffer
  417.  
  418. .checkForEnd:
  419.         mov     ax, [esi]
  420.         cmp     ax, 3B00h   ; ';'
  421.         jz      @f
  422. ; check for files not ending with separator
  423.         movzx   eax, byte [ebp-33]
  424.         add     eax, ebp
  425.         sub     eax, 34
  426.         cmp     esi, eax
  427.         jz      @f
  428. ; check the end of the directory
  429.         movzx   eax, byte [ebp-1]
  430.         add     eax, ebp
  431.         cmp     esi, eax
  432. @@:
  433.         ret
  434.  
  435. .utf16:
  436.         cmp     [cd_counter_block], 2
  437.         jbe     .utf16ParentDirectory
  438. @@:
  439.         lodsw
  440.         xchg    ah, al
  441.         stosw
  442.         call    .checkForEnd
  443.         jc      @b
  444. @@:
  445.         mov     [edi], word 0
  446.         add     [cd_mem_location], 560
  447.         jmp     .get_names_from_buffer
  448.  
  449. .utf16ParentDirectory:
  450.         stosw
  451.         cmp     [cd_counter_block], 2
  452.         jnz     @b
  453.         stosw
  454.         jmp     @b
  455.  
  456. cd_get_parameters_of_file:
  457.         mov     edi, [cd_mem_location]
  458. cd_get_parameters_of_file_1:
  459. ; get file attributes
  460.         xor     eax, eax
  461. ; file is not archived
  462.         inc     eax
  463.         shl     eax, 1
  464. ; is a directory?
  465.         test    [ebp-8], byte 2
  466.         jz      .file
  467.         inc     eax
  468. .file:
  469. ; not as a volume label in the FAT, in this form not available
  470. ; file is not a system
  471.         shl     eax, 3
  472. ; file is hidden? (attribute of existence)
  473.         test    [ebp-8], byte 1
  474.         jz      .hidden
  475.         inc     eax
  476. .hidden:
  477.         shl     eax, 1
  478. ; file is always read-only, as this CD
  479.         inc     eax
  480.         mov     [edi], eax
  481.         mov     eax, [ebx+4]
  482.         mov     [edi+4], eax
  483. ; get the time to file
  484. ; hour
  485.         movzx   eax, byte [ebp-12]
  486.         shl     eax, 8
  487. ; minute
  488.         mov     al, [ebp-11]
  489.         shl     eax, 8
  490. ; second
  491.         mov     al, [ebp-10]
  492. ; file creation time
  493.         mov     [edi+8], eax
  494. ; last access time
  495.         mov     [edi+16], eax
  496. ; last write time
  497.         mov     [edi+24], eax
  498. ; get date for file
  499. ; year
  500.         movzx   eax, byte [ebp-15]
  501.         add     eax, 1900
  502.         shl     eax, 8
  503. ; month
  504.         mov     al, [ebp-14]
  505.         shl     eax, 8
  506. ; day
  507.         mov     al, [ebp-13]
  508. ; file creation date
  509.         mov     [edi+12], eax
  510. ; last access date
  511.         mov     [edi+20], eax
  512. ; last write date
  513.         mov     [edi+28], eax
  514. ; get the file size in bytes
  515.         xor     eax, eax
  516.         mov     [edi+32+4], eax
  517.         mov     eax, [ebp-23]
  518.         mov     [edi+32], eax
  519.         ret
  520.  
  521. ;-----------------------------------------------------------------------------
  522. fs_CdGetFileInfo:
  523.         cmp     byte [esi], 0
  524.         jnz     @f
  525.  
  526.         mov     eax, 2
  527.         ret
  528. ;--------------------------------------
  529. @@:
  530.         push    edi
  531.         call    cd_find_lfn
  532.         pushfd
  533.         cmp     [DevErrorCode], 0
  534.         jz      @f
  535.  
  536.         popfd
  537.         pop     edi
  538.         mov     eax, 11
  539.         ret
  540. ;--------------------------------------
  541. @@:
  542.         popfd
  543.         jnc     @f
  544.  
  545.         pop     edi
  546.         mov     eax, ERROR_FILE_NOT_FOUND
  547.         ret
  548. ;--------------------------------------
  549. @@:
  550.  
  551.         mov     edi, edx
  552.         push    ebp
  553.         mov     ebp, [cd_current_pointer_of_input]
  554.         add     ebp, 33
  555.         call    cd_get_parameters_of_file_1
  556.         pop     ebp
  557.         and     dword [edi+4], 0
  558.         pop     edi
  559.         xor     eax, eax
  560.         ret
  561. ;-----------------------------------------------------------------------------
  562. cd_find_lfn:
  563.         mov     [cd_appl_data], 0
  564. ; in: esi -> path string in UTF-8
  565. ; out: [cd_current_pointer_of_input] -> direntry, CF=1 -> file not found
  566.         push    eax esi
  567. ; Sector 16 - start set of volume descriptors
  568.         call    WaitUnitReady
  569.         cmp     [DevErrorCode], 0
  570.         jne     .access_denied
  571.  
  572.         call    prevent_medium_removal
  573. ; testing of reading
  574.         mov     [CDSectorAddress], dword 16
  575.         mov     [CDDataBuf_pointer], CDDataBuf
  576.         call    ReadCDWRetr;_1
  577.         cmp     [DevErrorCode], 0
  578.         jne     .access_denied
  579.  
  580. ; calculation of the last session
  581.         call    WaitUnitReady
  582.         cmp     [DevErrorCode], 0
  583.         jne     .access_denied
  584.  
  585.         call    Read_TOC
  586.         mov     ah, [CDDataBuf+4+4]
  587.         mov     al, [CDDataBuf+4+5]
  588.         shl     eax, 16
  589.         mov     ah, [CDDataBuf+4+6]
  590.         mov     al, [CDDataBuf+4+7]
  591.         add     eax, 15
  592.         mov     [CDSectorAddress], eax
  593. ;  mov  [CDSectorAddress],dword 15
  594.         mov     [CDDataBuf_pointer], CDDataBuf
  595. ;--------------------------------------
  596. .start:
  597.         inc     dword [CDSectorAddress]
  598.         call    ReadCDWRetr;_1
  599.         cmp     [DevErrorCode], 0
  600.         jne     .access_denied
  601.  
  602. .start_check:
  603. ; checking for "lice"
  604.         cmp     [CDDataBuf+1], dword 'CD00'
  605.         jne     .access_denied
  606.  
  607.         cmp     [CDDataBuf+5], byte '1'
  608.         jne     .access_denied
  609. ; sector is the terminator of set of descriptors volumes?
  610.         cmp     [CDDataBuf], byte 0xff
  611.         je      .access_denied
  612. ; sector is an additional and improved descriptor of volume?
  613.         cmp     [CDDataBuf], byte 0x2
  614.         jne     .start
  615. ; sector is an additional descriptor of volume?
  616.         cmp     [CDDataBuf+6], byte 0x1
  617.         jne     .start
  618.  
  619. ; parameters of root directory
  620.         mov     eax, [CDDataBuf+0x9c+2]; start of root directory
  621.         mov     [CDSectorAddress], eax
  622.         mov     eax, [CDDataBuf+0x9c+10]; size of root directory
  623.         cmp     byte [esi], 0
  624.         jnz     @f
  625.  
  626.         mov     [cd_current_pointer_of_input], CDDataBuf+0x9c
  627.         jmp     .done
  628. ;--------------------------------------
  629. @@:
  630. ; start the search
  631. .mainloop:
  632.         dec     dword [CDSectorAddress]
  633. ;--------------------------------------
  634. .read_to_buffer:
  635.         inc     dword [CDSectorAddress]
  636.         mov     [CDDataBuf_pointer], CDDataBuf
  637.         call    ReadCDWRetr      ; read sector of directory
  638.         cmp     [DevErrorCode], 0
  639.         jne     .access_denied
  640.         call    cd_find_name_in_buffer
  641.         jnc     .found
  642.         sub     eax, 2048
  643. ; directory is over?
  644.         cmp     eax, 0
  645.         ja      .read_to_buffer
  646. ; desired element of chain is not found
  647. .access_denied:
  648.         pop     esi eax
  649.         mov     [cd_appl_data], 1
  650.         stc
  651.         ret
  652. ;--------------------------------------
  653. ; desired element of chain found
  654. .found:
  655. ; the end of the file path
  656.         cmp     byte [esi-1], 0
  657.         jz      .done
  658.         mov     eax, [cd_current_pointer_of_input]
  659.         push    dword [eax+2]
  660.         pop     dword [CDSectorAddress] ; beginning of the directory
  661.         mov     eax, [eax+2+8] ; size of directory
  662.         jmp     .mainloop
  663. ;--------------------------------------
  664. ; file pointer found
  665. .done:
  666.         pop     esi eax
  667.         mov     [cd_appl_data], 1
  668.         clc
  669.         ret
  670. ;-----------------------------------------------------------------------------
  671. cd_find_name_in_buffer:
  672.         mov     [cd_current_pointer_of_input_2], CDDataBuf
  673. ;--------------------------------------
  674. .start:
  675.         call    cd_get_name
  676.         jc      .not_found
  677.  
  678.         call    cd_compare_name
  679.         jc      .start
  680. ;--------------------------------------
  681. .found:
  682.         clc
  683.         ret
  684. ;--------------------------------------
  685. .not_found:
  686.         stc
  687.         ret
  688. ;-----------------------------------------------------------------------------
  689. cd_get_name:
  690.         push    eax
  691.         mov     ebp, [cd_current_pointer_of_input_2]
  692.         mov     [cd_current_pointer_of_input], ebp
  693.         mov     eax, [ebp]
  694.         test    eax, eax ; entry's is over?
  695.         jz      .next_sector
  696.  
  697.         cmp     ebp, CDDataBuf+2048  ; buffer is over?
  698.         jae     .next_sector
  699.  
  700.         movzx   eax, byte [ebp]
  701.         add     [cd_current_pointer_of_input_2], eax ; next entry of directory
  702.         add     ebp, 33; pointer is set to the beginning of the name
  703.         pop     eax
  704.         clc
  705.         ret
  706. ;--------------------------------------
  707. .next_sector:
  708.         pop     eax
  709.         stc
  710.         ret
  711. ;-----------------------------------------------------------------------------
  712. cd_compare_name:
  713. ; in: esi -> UTF-8 name, ebp -> UTF-16BE name
  714. ; out: CF=0 -> names match, esi -> next component of name
  715. ;      CF=1 -> esi is not changed
  716.         push    edx edi eax esi
  717.         mov     edi, ebp
  718. .loop:
  719.         call    utf8to16
  720.         call    utf16toUpper
  721.         mov     edx, eax
  722.         mov     ax, [edi]
  723.         xchg    al, ah
  724.         call    utf16toUpper
  725.         cmp     ax, dx
  726.         jne     .name_not_coincide
  727.         add     edi, 2
  728.         cmp     [esi], byte '/' ; path separator is end of current element
  729.         je      .done
  730.         cmp     [esi], byte 0 ; path separator end of name
  731.         jne     .loop
  732. .done:
  733. ; check end of file
  734.         cmp     [edi], word 3B00h; separator end of file ';'
  735.         je      .done_1
  736. ; check for files not ending with separator
  737.         movzx   eax, byte [ebp-33]
  738.         add     eax, ebp
  739.         sub     eax, 34
  740.         cmp     edi, eax
  741.         je      .done_1
  742. ; check the end of directory
  743.         movzx   eax, byte [ebp-1]
  744.         add     eax, ebp
  745.         cmp     edi, eax
  746.         jne     .name_not_coincide
  747. .done_1:
  748.         pop     eax eax edi edx
  749.         inc     esi
  750.         ret
  751.  
  752. .name_not_coincide:
  753.         pop     esi eax edi edx
  754.         stc
  755.         ret
  756.