support of "../" in the absolute file path

git-svn-id: svn://kolibrios.org@6787 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2016-12-05 19:44:57 +00:00
parent f1d65cb32f
commit 6aab6c5478

View File

@ -545,7 +545,7 @@ get_full_file_name:
cmp byte [ebx], 3 cmp byte [ebx], 3
jz .utf8 jz .utf8
call cp866toUTF8_string call cp866toUTF8_string
jns .ret jns .end
jmp .fail jmp .fail
.utf8: .utf8:
@ -554,12 +554,12 @@ get_full_file_name:
lodsb lodsb
stosb stosb
test al, al test al, al
jz .ret jz .end
jmp .utf8 jmp .utf8
.utf16: .utf16:
call UTF16to8_string call UTF16to8_string
jns .ret jns .end
.fail: .fail:
mov byte [edi], 0 mov byte [edi], 0
xor eax, eax xor eax, eax
@ -580,50 +580,9 @@ get_full_file_name:
cmp byte [ebx], 0 cmp byte [ebx], 0
jz .set_ok jz .set_ok
cmp byte [ebx], 4 cmp byte [ebx], 4
jnc .relative jnc @f
inc ebx
cmp byte [ebx-1], 2
jz .relative16
.relative:
cmp byte [ebx], 0
jz .set_ok
cmp word [ebx], '.'
jz .set_ok
cmp word [ebx], './'
jz .next
cmp word [ebx], '..'
jnz .doset_relative
cmp byte [ebx+2], 0
jz @f
cmp byte [ebx+2], '/'
jnz .doset_relative
inc ebx inc ebx
@@: @@:
dec esi
cmp byte [esi], '/'
jnz @b
.next:
add ebx, 2
jmp .relative
.set_ok:
cmp edx, edi ; is destination equal to cur_dir?
jz @f
mov ecx, esi
sub ecx, edx
mov esi, edx
rep movsb
mov byte [edi], 0
.ret:
mov al, 1
pop ebx ebp
ret 8
@@:
mov byte [esi], 0
jmp .ret
.doset_relative:
cmp edx, edi ; is destination equal to cur_dir? cmp edx, edi ; is destination equal to cur_dir?
mov edi, esi mov edi, esi
jz @f jz @f
@ -643,29 +602,67 @@ get_full_file_name:
mov ebx, [esp] mov ebx, [esp]
jmp .absolute jmp .absolute
.relative16: .set_ok:
cmp word [ebx], 0 cmp edx, edi ; is destination equal to cur_dir?
jz .set_ok
cmp word [ebx], '.'
jnz .doset_relative
cmp word [ebx+2], 0
jz .set_ok
cmp word [ebx+2], '/'
jz .next16
cmp word [ebx+2], '.'
jnz .doset_relative
cmp word [ebx+4], 0
jz @f jz @f
cmp word [ebx+4], '/' mov ecx, esi
jnz .doset_relative sub ecx, edx
add ebx, 2 mov esi, edx
rep movsb
mov byte [edi], 0
@@: @@:
dec esi mov al, 1
pop ebx ebp
ret 8
.end:
or ecx, -1
mov edi, [esp+12]
xor eax, eax
push edi
repnz scasb
not ecx
pop edi
.parse:
mov al, '/'
repnz scasb
jecxz @b
cmp byte [edi], '.'
jnz .parse
mov esi, edi
@@:
lodsw
sub ecx, 2
cmp ax, './'
jz @b
cmp ax, '..'
jnz @f
cmp byte [esi], '/' cmp byte [esi], '/'
jnz @b jnz @f
.next16: mov edx, ecx
add ebx, 4 mov ecx, edi
jmp .relative16 sub ecx, [esp+12]
sub ecx, 2
jc .fail
sub edi, 2
lodsb
dec edx
std
repnz scasb
cld
add edi, 2
mov ecx, edx
jmp @b
@@:
sub esi, 2
add ecx, 2
cmp esi, edi
jz .parse
push edi ecx
rep movsb
pop ecx edi
jmp .parse
include "parse_fn.inc" include "parse_fn.inc"
include "fs_common.inc" include "fs_common.inc"