123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- {
- System independent filecontrol interface for tp7
- $Id$
- }
- { no known 16 bit compilers support overriding }
- function OpenFileStr(FName: PChar; Flags: Longint): TFileHandle; assembler;
- asm
- @@Retry:
- push ds
- lds dx,FName
- mov al,byte ptr Flags
- mov ah,3dh
- int 21h
- pop ds
- jnc @@1
- push ax
- mov ax,0
- push ax { ErrorCode: Longint }
- les dx,FName
- push es
- push dx { FName as ErrorInfo }
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- mov ax,-1
- @@1:
- end;
- function CreateFileStr(FName: PChar): TFileHandle; assembler;
- asm
- @@Retry:
- push ds
- lds dx,FName
- mov cl,20h
- xor ch,ch
- mov ah,3Ch
- int 21h
- pop ds
- jnc @@1
- push ax
- mov ax,0
- push ax
- les dx,FName
- push es
- push dx { FName as errorinfo }
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- mov ax,-1
- @@1:
- end;
- procedure DeleteFileStr(FName: PChar); assembler;
- asm
- @@Retry:
- push ds
- lds dx,FName
- mov AH,41h
- int 21h
- pop ds
- jnc @@1
- push ax
- mov ax,0
- push ax
- les dx,FName
- push es
- push dx
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- @@1:
- end;
- procedure CloseFile(Handle: TFileHandle); assembler;
- asm
- @@Retry:
- mov bx,Handle
- mov ah,3eh
- int 21h
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- @@1:
- end;
- function SeekFile(Handle: TFileHandle; Pos: TFileInt; SeekType: Word): TFileInt; assembler;
- asm
- @@Retry:
- mov ah,42H
- mov bx,Handle
- mov dx,word ptr Pos[0]
- mov cx,word ptr Pos[2]
- mov al,byte ptr SeekType
- int 21h
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- mov ax,-1
- mov dx,-1
- @@1:
- end;
- function ReadFile(Handle: TFileHandle; var Buff; Count: CPUWord): CPUWord; assembler;
- asm
- @@Retry:
- push ds
- lds dx,Buff
- mov cx,Count
- mov bx,Handle
- mov ah,3fh
- int 21h
- pop ds
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- xor ax,ax
- @@1:
- end;
- function WriteFile(Handle: TFileHandle; var Buff; Count: CPUWord): CPUWord; assembler;
- asm
- @@Retry:
- push ds
- lds dx,Buff
- mov cx,Count
- mov bx,Handle
- mov ah,40h
- int 21h
- pop ds
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- xor ax,ax
- @@1:
- end;
- procedure FlushFile(Handle: TFileHandle); assembler;
- asm
- @@Retry:
- mov bx,Handle
- mov ah,68H
- int 21h
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- @@1:
- end;
- procedure TruncateFile(Handle: TFileHandle);
- begin
- WriteFile(Handle, Handle, 0);
- end;
- function EndOfFile(Handle: TFileHandle): Boolean; assembler;
- asm
- @@Retry:
- mov ax,4400h
- mov bx,Handle
- int 21h
- jnc @@1
- push ax
- mov ax,0
- push ax
- push ax
- push ax
- call [ErrorHandler]
- cmp ax,errRetry
- je @@Retry
- jmp @@3 { Set result to 1, though an error has happened }
- @@1:
- test ax,40h
- jz @@3
- xor al,al
- jmp @@2
- @@3:
- mov al,1
- @@2:
- end;
- function FilePos(Handle: TFileHandle): TFileInt;
- begin
- FilePos := SeekFile(Handle, 0, skCur);
- end;
- function FileSize(Handle: TFileHandle): TFileInt;
- var
- L: Longint;
- begin
- L := FilePos(Handle);
- FileSize := SeekFile(Handle, 0, skEnd);
- SeekFile(Handle, L, skBeg);
- end;
- {
- $Log$
- Revision 1.2 2000-07-13 11:32:26 michael
- + removed logs
-
- }
|