Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;------------------------------------------------------------------------------
  2. ;///// SORTING ////////////////////////////////////////////////////////////////
  3. ;------------------------------------------------------------------------------
  4.  
  5. r_sort db 1
  6. l_sort db 1
  7.  
  8. align 4
  9.  compare_table:
  10.   dd compare_by_name
  11.   dd compare_by_extension
  12.  
  13. ; AL = panel
  14. func mfar_sort
  15.         pusha
  16.         cmp     al,0
  17.         jne    ._00
  18.         mov     eax,[d_lcnt]
  19.         mov     edi,lstart
  20.         movzx   edx,[l_sort]
  21.         jmp     @f
  22.    ._00:
  23.         mov     eax,[d_rcnt]
  24.         mov     edi,rstart
  25.         movzx   edx,[r_sort]
  26.     @@:
  27.         mov     edx,[edx*4+compare_table]
  28.         cmp     eax,2
  29.         jbe    .exit
  30.         dec     eax
  31.         shl     eax,4
  32.         add     eax,edi
  33.         cmp     word[edi],'..'
  34.         jne     @f
  35.         add     edi,16
  36.     @@:
  37.         push    edi
  38.         mov     esi,edi
  39.         add     edi,16
  40.    .next_file:
  41.         call    edx
  42.         add     edi,16
  43.         cmp     edi,eax
  44.         jbe    .next_file
  45.  
  46.         mov     ebx,12
  47.     @@:
  48.         mov     ecx,[ebx+eax]
  49.         xchg    [ebx+esi],ecx
  50.         mov     [ebx+eax],ecx
  51.         sub     ebx,4
  52.         jge     @b
  53.  
  54.         mov     esi,[esp]
  55.         mov     edi,esi
  56.         add     edi,16
  57.  
  58.         sub     eax,16
  59.         cmp     eax,edi
  60.         jge    .next_file
  61.         pop     edi
  62.  
  63.  .exit:
  64.         popad
  65.         ret
  66. endf
  67.  
  68. ;------------------------------------------------------------------------------
  69.  
  70. ; ESI = pointer to 1st file info
  71. ; EDI = pointer to 2nd file info
  72. func compare_by_name
  73.         mov     ecx,11
  74.         push    edi esi
  75.         repe    cmpsb
  76.         pop     esi edi
  77.         pushfd
  78.         test    byte[esi+11],FA_FOLDER
  79.         jnz    ._00
  80.         test    byte[edi+11],FA_FOLDER
  81.         jz     ._01
  82.         jmp    ._03
  83.    ._00:
  84.         test    byte[edi+11],FA_FOLDER
  85.         jz     ._02
  86.    ._01:
  87.         popfd
  88.         jg     ._04
  89.         mov     esi,edi
  90.         ret
  91.    ._02:
  92.         popfd
  93.         mov     esi,edi
  94.         ret
  95.    ._03:
  96.         popfd
  97.    ._04:
  98.         ret
  99. endf
  100.  
  101. ;------------------------------------------------------------------------------
  102.  
  103. ; ESI = pointer to 1st file info
  104. ; EDI = pointer to 2nd file info
  105. func compare_by_extension
  106.         push    edi esi
  107.         mov     ecx,3
  108.         add     esi,8
  109.         add     edi,8
  110.         repe    cmpsb
  111.         jne    ._00
  112.         mov     esi,[esp]
  113.         mov     edi,[esp+4]
  114.         mov     ecx,8
  115.         repe    cmpsb
  116.    ._00:
  117.         pop     esi edi
  118.         pushfd
  119.         test    byte[esi+11],FA_FOLDER
  120.         jnz    ._01
  121.         test    byte[edi+11],FA_FOLDER
  122.         jz     ._02
  123.         jmp    ._04
  124.    ._01:
  125.         test    byte[edi+11],FA_FOLDER
  126.         jz     ._03
  127.    ._02:
  128.         popfd
  129.         jg     ._05
  130.         mov     esi,edi
  131.         ret
  132.    ._03:
  133.         popfd
  134.         mov     esi,edi
  135.         ret
  136.    ._04:
  137.         popfd
  138.    ._05:
  139.         ret
  140. endf