mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 23:19:24 +02:00
* basic file io fixed for win64
git-svn-id: trunk@3241 -
This commit is contained in:
parent
61d86150aa
commit
807fc6e948
@ -209,7 +209,7 @@ Var
|
|||||||
security : TSecurityAttributes;
|
security : TSecurityAttributes;
|
||||||
begin
|
begin
|
||||||
AllowSlash(p);
|
AllowSlash(p);
|
||||||
{ close first if opened }
|
{ close first if opened }
|
||||||
if ((flags and $10000)=0) then
|
if ((flags and $10000)=0) then
|
||||||
begin
|
begin
|
||||||
case filerec(f).mode of
|
case filerec(f).mode of
|
||||||
@ -223,9 +223,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ reset file handle }
|
{ reset file handle }
|
||||||
filerec(f).handle:=UnusedHandle;
|
filerec(f).handle:=UnusedHandle;
|
||||||
{ convert filesharing }
|
{ convert filesharing }
|
||||||
shflags:=0;
|
shflags:=0;
|
||||||
if ((filemode and fmshareExclusive) = fmshareExclusive) then
|
if ((filemode and fmshareExclusive) = fmshareExclusive) then
|
||||||
{ no sharing }
|
{ no sharing }
|
||||||
@ -238,7 +238,7 @@ begin
|
|||||||
else
|
else
|
||||||
if ((filemode and fmshareDenyNone) = fmshareDenyNone) then
|
if ((filemode and fmshareDenyNone) = fmshareDenyNone) then
|
||||||
shflags := file_Share_Read + file_Share_Write;
|
shflags := file_Share_Read + file_Share_Write;
|
||||||
{ convert filemode to filerec modes }
|
{ convert filemode to filerec modes }
|
||||||
case (flags and 3) of
|
case (flags and 3) of
|
||||||
0 : begin
|
0 : begin
|
||||||
filerec(f).mode:=fminput;
|
filerec(f).mode:=fminput;
|
||||||
@ -253,13 +253,13 @@ begin
|
|||||||
oflags:=longint(GENERIC_WRITE or GENERIC_READ);
|
oflags:=longint(GENERIC_WRITE or GENERIC_READ);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ create it ? }
|
{ create it ? }
|
||||||
if (flags and $1000)<>0 then
|
if (flags and $1000)<>0 then
|
||||||
cd:=CREATE_ALWAYS
|
cd:=CREATE_ALWAYS
|
||||||
{ or Append/Open ? }
|
{ or Append/Open ? }
|
||||||
else
|
else
|
||||||
cd:=OPEN_EXISTING;
|
cd:=OPEN_EXISTING;
|
||||||
{ empty name is special }
|
{ empty name is special }
|
||||||
if p[0]=#0 then
|
if p[0]=#0 then
|
||||||
begin
|
begin
|
||||||
case FileRec(f).mode of
|
case FileRec(f).mode of
|
||||||
@ -280,7 +280,8 @@ begin
|
|||||||
security.bInheritHandle:=true;
|
security.bInheritHandle:=true;
|
||||||
security.lpSecurityDescriptor:=nil;
|
security.lpSecurityDescriptor:=nil;
|
||||||
filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
|
filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
|
||||||
{ append mode }
|
|
||||||
|
{ append mode }
|
||||||
if ((flags and $100)<>0) and
|
if ((flags and $100)<>0) and
|
||||||
(filerec(f).handle<>0) and
|
(filerec(f).handle<>0) and
|
||||||
(filerec(f).handle<>UnusedHandle) then
|
(filerec(f).handle<>UnusedHandle) then
|
||||||
@ -288,7 +289,8 @@ begin
|
|||||||
do_seekend(filerec(f).handle);
|
do_seekend(filerec(f).handle);
|
||||||
filerec(f).mode:=fmoutput; {fool fmappend}
|
filerec(f).mode:=fmoutput; {fool fmappend}
|
||||||
end;
|
end;
|
||||||
{ get errors }
|
|
||||||
|
{ get errors }
|
||||||
{ handle -1 is returned sometimes !! (PM) }
|
{ handle -1 is returned sometimes !! (PM) }
|
||||||
if (filerec(f).handle=0) or (filerec(f).handle=UnusedHandle) then
|
if (filerec(f).handle=0) or (filerec(f).handle=UnusedHandle) then
|
||||||
begin
|
begin
|
||||||
|
@ -132,7 +132,7 @@ type
|
|||||||
PLPWSTR = ^LPWSTR;
|
PLPWSTR = ^LPWSTR;
|
||||||
|
|
||||||
PSecurityAttributes = ^TSecurityAttributes;
|
PSecurityAttributes = ^TSecurityAttributes;
|
||||||
TSecurityAttributes = packed record
|
TSecurityAttributes = record
|
||||||
nLength : DWORD;
|
nLength : DWORD;
|
||||||
lpSecurityDescriptor : Pointer;
|
lpSecurityDescriptor : Pointer;
|
||||||
bInheritHandle : BOOL;
|
bInheritHandle : BOOL;
|
||||||
@ -235,7 +235,7 @@ threadvar
|
|||||||
stdcall;external KernelDLL name 'MoveFileA';
|
stdcall;external KernelDLL name 'MoveFileA';
|
||||||
function CreateFile(lpFileName:pchar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
|
function CreateFile(lpFileName:pchar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
|
||||||
lpSecurityAttributes:PSECURITYATTRIBUTES; dwCreationDisposition:DWORD;
|
lpSecurityAttributes:PSECURITYATTRIBUTES; dwCreationDisposition:DWORD;
|
||||||
dwFlagsAndAttributes:DWORD; hTemplateFile:DWORD):longint;
|
dwFlagsAndAttributes:DWORD; hTemplateFile:DWORD):THandle;
|
||||||
stdcall;external KernelDLL name 'CreateFileA';
|
stdcall;external KernelDLL name 'CreateFileA';
|
||||||
function GetProcAddress(hModule:THandle; lpProcName:pchar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
|
function GetProcAddress(hModule:THandle; lpProcName:pchar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ type
|
|||||||
|
|
||||||
const
|
const
|
||||||
{ Default filehandles }
|
{ Default filehandles }
|
||||||
UnusedHandle : THandle = -1;
|
UnusedHandle : THandle = THandle(-1);
|
||||||
StdInputHandle : THandle = 0;
|
StdInputHandle : THandle = 0;
|
||||||
StdOutputHandle : THandle = 0;
|
StdOutputHandle : THandle = 0;
|
||||||
StdErrorHandle : THandle = 0;
|
StdErrorHandle : THandle = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user