Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
file_handler:
135 diamond 2
 .operation=0
3
 .position=4
4
 .reserved=8
5
 .n_bytes=12
6
 .bufer=16
7
 .name=20
8
 .st_size=20+1024
31 halyavin 9
 
10
open: ;esi=name_string
11
      ;retorna eax
12
	pushad
13
	mov ecx,file_handler.st_size
14
	call mallocz
15
	mov [esp+28],edi
135 diamond 16
	push edi
17
	mov ecx,1024
31 halyavin 18
	add edi,file_handler.name
19
	call movedata
20
	pop edi
135 diamond 21
; test if file exists
22
	lea ebx,[edi+file_handler.operation]
23
	mov byte[ebx],5
24
	mov dword[ebx+16],fileattr
25
	mov eax,70
26
	int 0x40
27
	cmp eax,2
28
	jz .virtual
31 halyavin 29
	test eax,eax
30
	jnz close.b
135 diamond 31
@@:
31 halyavin 32
	clc
33
	popad
34
	ret
135 diamond 35
.virtual:
36
        mov     byte [fileattr], 0x10
37
        jmp     @b
31 halyavin 38
 
39
close:
40
	pushad
41
     .b:
135 diamond 42
	mov edi,[esp+28]
31 halyavin 43
	call free
44
	popad
45
	xor eax,eax
46
	ret
47
 
48
 
49
read:     ;(f,bufer,nbytes)  eax,edi,ecx ncr
50
	  ;retorna bytes leidos en ecx
51
	pushad
135 diamond 52
	lea     ebx, [eax+file_handler.operation]
53
	mov     byte [ebx], 0
54
	mov     [ebx+12], ecx
55
	mov     [ebx+16], edi
56
	mov     eax, 70
57
	int     0x40
58
	cmp     ebx, -1
59
	sbb     ebx, -1
60
	mov     eax, [esp+28]
61
	add     [eax+file_handler.position], ebx
62
	mov     [esp+24], ebx
31 halyavin 63
	popad
64
	ret
65
 
66
ftell:  mov edx,[eax+file_handler.position]
67
	ret
68
lseek: ;eax=file edx=pos
69
	mov [eax+file_handler.position],edx
70
	ret
71
skip:   ;eax=file edx=bytes to skip
72
	add [eax+file_handler.position],edx
73
	ret
74