Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6797 → Rev 6798

/kernel/trunk/fs/ext.inc
1900,13 → 1900,15
mov esi, [esp+12]
movzx ecx, [esi+DIRENTRY.nameLength]
lea esi, [esi+DIRENTRY.name]
add ecx, esi
cmp byte [esi], '.'
jnz @f
or byte [edx], KOS_HIDDEN
@@:
lea edi, [edx+40]
cmp byte [edx+4], 1
cmp byte [edx+4], 3
jz .utf8
add ecx, esi
cmp byte [edx+4], 2
jz .utf16
@@:
call utf8to16
1932,6 → 1934,12
push .wanted_start
jmp .end_block
 
.utf8:
rep movsb
mov byte [edi], 0
add edx, 40+520
jmp @b
 
.utf16:
call utf8to16
stosw
/kernel/trunk/fs/fat.inc
1410,26 → 1410,36
push edi esi
mov edi, esi
mov esi, ebp
test byte [ebp-4], 1
jz .ansi
.uni:
cmp byte [ebp-4], 2
jz .utf16
cmp byte [ebp-4], 3
jz .utf8
@@:
lodsw
stosw
test eax, eax
jnz .uni
call uni2ansi_char
stosb
test al, al
jnz @b
pop esi edi
add esi, 520
add esi, 264
.ret:
ret
 
.ansi:
.utf8:
push ecx
mov ecx, 519
call UTF16to8_string
pop ecx
jmp @f
 
.utf16:
lodsw
call uni2ansi_char
stosb
test al, al
jnz .ansi
stosw
test eax, eax
jnz .utf16
@@:
pop esi edi
add esi, 264
add esi, 520
ret
 
bdfe_to_fat_entry:
/kernel/trunk/fs/fs_lfn.inc
38,31 → 38,30
mov [image_of_ebx], ebx
ret
 
fileSystemUnicode:
; in: ebx -> f.80 parameter structure
mov edi, [ebx+20]
mov esi, [ebx+24]
jmp @f
 
file_system_lfn:
; in: ebx -> parameter structure
lea ebp, [ebx+20]
cmp byte [ebp], 0
; in: ebx -> f.70 parameter structure
xor edi, edi
lea esi, [ebx+20]
cmp byte [esi], 0
jnz @f
mov ebp, [ebx+21]
mov esi, [ebx+21]
@@:
cmp word [ebp], '/'
jz .rootdir
cmp byte [ebp], 4
jnc @f
cmp byte [ebp], 0
jz @f
cmp word [ebp+1], '/'
cmp word [esi], '/'
jnz @f
cmp byte [ebp], 2
cmp edi, 2
jnz .rootdir
cmp word [ebp+3], 0
cmp dword[esi], '/'
jz .rootdir
@@:
stdcall kernel_alloc, maxPathLength
push eax ebx
xchg eax, edi
mov esi, ebp
xor eax, eax
call getFullPath
pop ebx ebp
test eax, eax
367,9 → 366,11
lodsb
test al, al
jz .cont
or al, 20h
scasb
jz @b
or al, 20h
cmp [edi-1], al
jz @b
.cont:
pop edi esi
inc edi
397,6 → 398,7
sys_current_directory: ; sysfunction 30
mov eax, [current_slot]
mov edi, [eax+APPDATA.cur_dir]
xor eax, eax
dec ebx
jz .set
dec ebx
403,8 → 405,12
jz .get
dec ebx
jz .mount_additional_directory
mov eax, edx
dec ebx
jz .get16
jz .set
mov eax, esi
dec ebx
jz .get
@@:
ret
 
416,26 → 422,17
jnz @b
mov esi, ecx
mov edi, sysdir_name1
mov ecx, 63
mov ecx, 64
rep movsb ; copying fake directory name
inc esi
xor eax, eax
stosb ; terminator of name, in case if we get the inlet trash
mov byte [edi-1], 0
mov cl, 63
cmp word [esi], 2
jz .utf16
call cp866toUTF8_string
@@:
mov byte [edi], 0
mov [full_file_name_table.size], 2
ret
 
.utf16:
add esi, 2
call UTF16to8_string
jmp @b
 
.get: ; in: ecx -> buffer, edx = length
.get:
; in: ecx -> buffer, edx = length, eax = encoding
mov esi, edi
inc esi
mov edi, ecx
444,6 → 441,11
mov edx, maxPathLength
@@:
mov ecx, edx
jecxz .ret
cmp eax, 2
jz .get16
cmp eax, 3
jz .get8
@@:
dec ecx
js @f
453,21 → 455,26
test al, al
jnz @b
sub edx, ecx
mov ecx, edx
@@:
mov [esp+32], ecx
mov byte [edi-1], 0
.ret:
mov [esp+32], edx
ret
 
.get8:
push edi
mov edi, esi
xor eax, eax
repnz scasb
sub edx, ecx
mov ecx, edx
pop edi
rep movsb
jmp @b
 
.get16:
mov esi, edi
inc esi
mov edi, ecx
cmp edx, maxPathLength
jc @f
mov edx, maxPathLength
@@:
shr ecx, 1
shr edx, 1
mov ecx, edx
@@:
dec ecx
js @f
476,14 → 483,13
test ax, ax
jnz @b
sub edx, ecx
mov ecx, edx
@@:
mov [esp+32], ecx
ret
shl edx, 1
mov word [edi-2], 0
jmp .ret
 
.set:
mov esi, ecx
xor eax, eax
getFullPath:
; in: esi -> file path, eax = string encoding, edi -> destination
; out: UTF-8 string (with marker), eax = length, 0 -> error
/kernel/trunk/fs/iso9660.inc
297,34 → 297,44
push edi
call cd_find_lfn
jnc .found
 
pop edi
cmp [DevErrorCode], 0
jne .noaccess_1
 
or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND
ret
;--------------------------------------
 
.found:
mov edi, [cd_current_pointer_of_input]
test byte [edi+25], 10b ; do not allow read directories
jnz .found_dir
 
pop edi
;--------------------------------------
.noaccess_1:
or ebx, -1
mov eax, ERROR_ACCESS_DENIED
ret
;--------------------------------------
 
.end_buffer:
pop edx eax
sub eax, 2048 ; directory is over?
ja .read_to_buffer
mov eax, [cd_counter_block]
mov [edx+8], eax
mov eax, [ebx]
sub [edx+4], eax
xor eax, eax
dec ecx
js @f
mov al, ERROR_END_OF_FILE
@@:
pop ecx edi
mov ebx, [edx+4]
ret
 
.found_dir:
mov eax, [edi+2] ; eax=cluster
mov [CDSectorAddress], eax
mov eax, [edi+10] ; directory size
;--------------------------------------
.doit:
; init header
push eax ecx
mov edi, edx
mov ecx, 32/4
334,11 → 344,9
mov byte [edx], 1 ; version
mov [cd_mem_location], edx
add [cd_mem_location], 32
;.mainloop:
mov [cd_counter_block], dword 0
dec dword [CDSectorAddress]
push ecx
;--------------------------------------
.read_to_buffer:
inc dword [CDSectorAddress]
mov [CDDataBuf_pointer], CDDataBuf
345,142 → 353,106
call ReadCDWRetr ; read sector of directory
cmp [DevErrorCode], 0
jne .noaccess_1
 
call .get_names_from_buffer
sub eax, 2048
; directory is over?
ja .read_to_buffer
 
mov edi, [cd_counter_block]
mov [edx+8], edi
mov edi, [ebx]
sub [edx+4], edi
xor eax, eax
dec ecx
js @f
 
mov al, ERROR_END_OF_FILE
;--------------------------------------
@@:
pop ecx edi
mov ebx, [edx+4]
ret
;--------------------------------------
mov [cd_current_pointer_of_input_2], CDDataBuf
push eax edx
.get_names_from_buffer:
mov [cd_current_pointer_of_input_2], CDDataBuf
push eax esi edi edx
;--------------------------------------
.get_names_from_buffer_1:
call cd_get_name
jc .end_buffer
 
inc dword [cd_counter_block]
mov eax, [cd_counter_block]
cmp [ebx], eax
jae .get_names_from_buffer_1
 
jae .get_names_from_buffer
test ecx, ecx
jz .get_names_from_buffer_1
 
jz .get_names_from_buffer
mov edi, [cd_counter_block]
mov [edx+4], edi
dec ecx
mov esi, ebp
mov edi, [cd_mem_location]
call cd_get_parameters_of_file
add edi, 40
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode
;--------------------------------------
.ansi:
mov ax, '.'
cmp dword[ebx+4], 2
jz .utf16
cmp dword[ebx+4], 3
jz .utf8
cmp [cd_counter_block], 2
jbe .ansi_parent_directory
 
cld
jbe .parentDirectory
@@:
lodsw
xchg ah, al
call uni2ansi_char
cld
stosb
; check end of file
mov ax, [esi]
cmp ax, word 3B00h ; separator end of file ';'
je .cd_get_parameters_of_file_1
; check for files not ending with separator
movzx eax, byte [ebp-33]
add eax, ebp
sub eax, 34
cmp esi, eax
je .cd_get_parameters_of_file_1
; check the end of the directory
movzx eax, byte [ebp-1]
add eax, ebp
cmp esi, eax
jb .ansi
;--------------------------------------
.cd_get_parameters_of_file_1:
call .checkForEnd
jc @b
@@:
mov [edi], byte 0
call cd_get_parameters_of_file
add [cd_mem_location], 304
jmp .get_names_from_buffer_1
;--------------------------------------
.ansi_parent_directory:
jmp .get_names_from_buffer
 
.parentDirectory:
stosb
cmp [cd_counter_block], 2
je @f
jnz @b
stosb
jmp @b
 
mov [edi], byte '.'
inc edi
jmp .cd_get_parameters_of_file_1
;--------------------------------------
.utf8:
add [cd_mem_location], 256
cmp [cd_counter_block], 2
jbe .parentDirectory
push ecx
mov ecx, 519
@@:
mov [edi], word '..'
add edi, 2
jmp .cd_get_parameters_of_file_1
;--------------------------------------
.unicode:
cmp [cd_counter_block], 2
jbe .unicode_parent_directory
lodsw
xchg ah, al
call UTF16to8
js @f
call .checkForEnd
jc @b
@@:
pop ecx
mov [edi], byte 0
add [cd_mem_location], 304
jmp .get_names_from_buffer
 
cld
movsw
; check end of file
.checkForEnd:
mov ax, [esi]
cmp ax, word 3B00h; separator end of file ';'
je .cd_get_parameters_of_file_2
cmp ax, 3B00h ; ';'
jz @f
; check for files not ending with separator
movzx eax, byte [ebp-33]
add eax, ebp
sub eax, 34
cmp esi, eax
je .cd_get_parameters_of_file_2
jz @f
; check the end of the directory
movzx eax, byte [ebp-1]
add eax, ebp
cmp esi, eax
jb .unicode
;--------------------------------------
.cd_get_parameters_of_file_2:
@@:
ret
 
.utf16:
cmp [cd_counter_block], 2
jbe .utf16ParentDirectory
@@:
lodsw
xchg ah, al
stosw
call .checkForEnd
jc @b
@@:
mov [edi], word 0
call cd_get_parameters_of_file
add [cd_mem_location], 560
jmp .get_names_from_buffer_1
;--------------------------------------
.unicode_parent_directory:
jmp .get_names_from_buffer
 
.utf16ParentDirectory:
stosw
cmp [cd_counter_block], 2
je @f
jnz @b
stosw
jmp @b
 
mov [edi], word 2E00h; '.'
add edi, 2
jmp .cd_get_parameters_of_file_2
;--------------------------------------
@@:
mov [edi], dword 2E002E00h; '..'
add edi, 4
jmp .cd_get_parameters_of_file_2
;--------------------------------------
.end_buffer:
pop edx edi esi eax
ret
;-----------------------------------------------------------------------------
cd_get_parameters_of_file:
mov edi, [cd_mem_location]
cd_get_parameters_of_file_1:
492,9 → 464,7
; is a directory?
test [ebp-8], byte 2
jz .file
 
inc eax
;--------------------------------------
.file:
; not as a volume label in the FAT, in this form not available
; file is not a system
502,14 → 472,14
; file is hidden? (attribute of existence)
test [ebp-8], byte 1
jz .hidden
 
inc eax
;--------------------------------------
.hidden:
shl eax, 1
; file is always read-only, as this CD
inc eax
mov [edi], eax
mov eax, [ebx+4]
mov [edi+4], eax
; get the time to file
; hour
movzx eax, byte [ebp-12]
541,19 → 511,6
mov [edi+20], eax
; last write date
mov [edi+28], eax
; get the data type of name
xor eax, eax
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode_1
 
mov [edi+4], eax
jmp @f
;--------------------------------------
.unicode_1:
inc eax
mov [edi+4], eax
;--------------------------------------
@@:
; get the file size in bytes
xor eax, eax
mov [edi+32+4], eax
/kernel/trunk/fs/ntfs.inc
1676,23 → 1676,22
mov al, '.'
push edi ecx
lea ecx, [esi+1]
test byte [edi-0x24], 1
cmp dword[edi-36], 2
jz .utf16sp
rep stosb
mov byte [edi], 0
pop ecx edi
cmp dword[edi-36], 3
jz @f
rep stosw
pop ecx
xor eax, eax
stosw
pop edi
add edi, 520
add edi, 264
ret
 
.utf16sp:
rep stosw
mov word [edi], 0
pop ecx edi
@@:
rep stosb
pop ecx
xor eax, eax
stosb
pop edi
add edi, 264
add edi, 520
.ret:
ret
 
1701,9 → 1700,10
cmp byte [esi+namespace], 2
jz .ret
; do not return system files
; ... note that there will be no bad effects if system files also were reported ...
cmp dword [esi+fileRecordReference], 0x10
cmp dword[esi+fileRecordReference], 16
jb .ret
cmp byte [esi+fileNameLength], 0
jz .ret
mov eax, [edx]
inc dword [eax+8] ; new file found
dec ebx
1716,33 → 1716,42
push ecx esi edi
movzx ecx, byte [esi+fileNameLength]
add esi, fileName
test byte [edi-0x24], 1
jz .ansi
shr ecx, 1
rep movsd
adc ecx, ecx
rep movsw
and word [edi], 0
pop edi
add edi, 520
pop esi ecx
ret
 
.ansi:
jecxz .skip
cmp dword[edi-36], 2
jz .utf16
cmp dword[edi-36], 3
jz .utf8
@@:
lodsw
call uni2ansi_char
stosb
loop @b
.skip:
xor al, al
stosb
pop edi
mov byte [edi], 0
pop edi esi ecx
add edi, 264
pop esi ecx
ret
 
.utf8:
push ecx
mov cx, 519
@@:
lodsw
call UTF16to8
js @f
dec dword[esp]
jnz @b
@@:
mov byte [edi], 0
pop edi
@@:
pop edi esi ecx
add edi, 520
ret
 
.utf16:
rep movsw
mov word [edi], 0
jmp @b
 
ntfs_direntry_to_bdfe:
mov [edi+4], eax ; ANSI/UNICODE name
mov eax, [esi+fileFlags]