|
@@ -65,9 +65,9 @@ begin
|
|
|
StrDispose(P);
|
|
|
end ;
|
|
|
|
|
|
+
|
|
|
{ Native OpenFile function.
|
|
|
if return value <> 0 call failed. }
|
|
|
-
|
|
|
function OpenFile(const FileName: string; var Handle: longint; Mode, Action: word): longint;
|
|
|
var
|
|
|
Regs: registers;
|
|
@@ -75,17 +75,34 @@ begin
|
|
|
result := 0;
|
|
|
Handle := 0;
|
|
|
StringToTB(FileName);
|
|
|
- if LFNSupport then Regs.Eax:=$716c
|
|
|
- else Regs.Eax:=$6c00;
|
|
|
- Regs.Edx := Action; { Action if file exists/not exists }
|
|
|
- Regs.Ds := tb_segment;
|
|
|
- Regs.Esi := tb_offset;
|
|
|
- Regs.Ebx := $2000 + (Mode and $ff); { file open mode }
|
|
|
- Regs.Ecx := $20; { Attributes }
|
|
|
+ if LFNSupport then
|
|
|
+ Regs.Eax := $716c { Use LFN Open/Create API }
|
|
|
+ else { Check if Extended Open/Create API is safe to use }
|
|
|
+ if lo(dosversion) < 7 then
|
|
|
+ Regs.Eax := $3d00 + (Mode and $ff) { For now, map to Open API }
|
|
|
+ else
|
|
|
+ Regs.Eax := $6c00; { Use Extended Open/Create API }
|
|
|
+ if Regs.Ah = $3d then
|
|
|
+ begin
|
|
|
+ if (Action and $00f0) <> 0 then
|
|
|
+ Regs.Eax := $3c00; { Map to Create/Replace API }
|
|
|
+ Regs.Ds := tb_segment;
|
|
|
+ Regs.Edx := tb_offset;
|
|
|
+ end
|
|
|
+ else { LFN or Extended Open/Create API }
|
|
|
+ begin
|
|
|
+ Regs.Edx := Action; { Action if file exists/not exists }
|
|
|
+ Regs.Ds := tb_segment;
|
|
|
+ Regs.Esi := tb_offset;
|
|
|
+ Regs.Ebx := $2000 + (Mode and $ff); { file open mode }
|
|
|
+ end;
|
|
|
+ Regs.Ecx := $20; { Attributes }
|
|
|
RealIntr($21, Regs);
|
|
|
- if Regs.Flags and CarryFlag <> 0 then result := Regs.Ax
|
|
|
- else Handle := Regs.Ax;
|
|
|
-end ;
|
|
|
+ if (Regs.Flags and CarryFlag) <> 0 then
|
|
|
+ result := Regs.Ax
|
|
|
+ else
|
|
|
+ Handle := Regs.Ax;
|
|
|
+end;
|
|
|
|
|
|
|
|
|
Function FileOpen (Const FileName : string; Mode : Integer) : Longint;
|
|
@@ -751,7 +768,10 @@ Finalization
|
|
|
end.
|
|
|
{
|
|
|
$Log$
|
|
|
- Revision 1.17 2003-10-25 23:42:35 hajny
|
|
|
+ Revision 1.18 2003-11-05 11:42:27 florian
|
|
|
+ * applied patch from Joe da Silva to fix OpenFile on older DOS versions
|
|
|
+
|
|
|
+ Revision 1.17 2003/10/25 23:42:35 hajny
|
|
|
* THandle in sysutils common using System.THandle
|
|
|
|
|
|
Revision 1.16 2003/06/03 07:54:27 michael
|
|
@@ -784,4 +804,4 @@ end.
|
|
|
Revision 1.7 2002/01/19 11:57:55 peter
|
|
|
* merged fixes
|
|
|
|
|
|
-}
|
|
|
+}
|