Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. fat32_parse_dir:
  2. ; in: eax=directory cluster
  3. ; out: eax=entry cluster
  4.         xor     bx, bx
  5.         mov     di, bx
  6.         push    eax
  7.         call    read_cluster
  8.         movzx   cx, byte [7C0Dh]
  9.         shl     cx, 4
  10. .scan_cluster:
  11.         pop     eax
  12.         cmp     byte [es:di], 0
  13.         jz      file_not_found
  14.         mov     si, [esp+2]
  15.         push    eax
  16.         call    fat_compare_name
  17.         jz      .file_found
  18.         and     di, not 1Fh
  19.         add     di, 20h
  20.         loop    .scan_cluster
  21.         pop     eax
  22.         call    next_cluster
  23.         jnc     file_not_found
  24.         jc      fat32_parse_dir
  25. .file_found:
  26.         pop     eax
  27.         mov     si, [esp+2]
  28.         mov     [cur_obj], si
  29.         and     di, not 1Fh
  30.         mov     si, directory_string
  31.         mov     ax, [es:di+14h]
  32.         and     ax, 0xFFF
  33.         shl     eax, 10h
  34.         mov     ax, [es:di+1Ah]
  35.         test    eax, eax
  36.         mov     si, nodata_string
  37.         jz      find_error_si
  38.         ret     2
  39.  
  40. fat_compare_name:
  41.         push    cx
  42.         mov     cx, 9
  43. .scan:
  44.         lodsb
  45.         cmp     al, '.'
  46.         jz      .ext
  47.         cmp     al, 0
  48.         jz      .nameend
  49.         cmp     al, 'a'
  50.         jb      .notletter
  51.         cmp     al, 'z'
  52.         ja      .notletter
  53.         or      byte [es:di], 20h
  54. .notletter:
  55.         scasb
  56.         loopz   .scan
  57. .notfound:
  58.         inc     cx      ; to clear ZF flag
  59.         pop     cx
  60.         ret
  61. .ext:
  62.         mov     al, ' '
  63.         dec     cx
  64.         repz    scasb
  65.         jnz     .notfound
  66.         test    di, 1
  67.         jnz     .notfound
  68.         mov     cx, 4
  69.         jmp     .scan
  70. .nameend:
  71.         mov     al, ' '
  72.         dec     cx
  73.         repz    scasb
  74.         jnz     .notfound
  75.         test    di, 1
  76.         jnz     .file_found
  77.         mov     cx, 3
  78.         repz    scasb
  79.         jnz     .notfound
  80. .file_found:
  81.         xor     cx, cx  ; to set ZF flag
  82.         pop     cx
  83.         ret
  84.