Zitat von
gsh:
ahm des mag ich überhaupt nicht
Und was stört dich daran?
Zitat von
gsh:
geht es nicht z.b. über TFileStream.Create(const AFileName: string; Mode: Word; Flags: word);
Aber genau sowas kannst du dir doch bauen damit:
Delphi-Quellcode:
TFlagFileStream =
Class(THandleStream)
Public
Constructor Create(
const FileName:
string;
const AMode: word);
Destructor Destroy;
Override;
End;
...
constructor TFlagFileStream.Create(
const FileName:
string;
const Mode: word; Flags: Word)
var
lHandle: THandle;
begin
if AMode = fmCreate
then
begin
lHandle := CreateFile(PChar(FileName), GENERIC_READ
Or GENERIC_WRITE,
0,
Nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL
or Flags, 0);
if lHandle < 0
then
raise EFCreateError.CreateResFmt(PResStringRec(@SFCreateError), [FileName]);
end
else
begin
lHandle := CreateFile(PChar(FileName), GENERIC_READ
Or GENERIC_WRITE,
0,
Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL
or Flags, 0);
if lHandle < 0
then
raise EFOpenError.CreateResFmt(PResStringRec(@SFOpenError), [FileName]);
end;
inherited Create(lHandle);
end;
destructor TFlagFileStream.Destroy;
begin
FileClose(
Handle);
inherited;
end;