mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 01:45:57 +02:00
+ Implemented Handle/FileStreams
This commit is contained in:
parent
fee3832edb
commit
393e12a636
@ -458,22 +458,22 @@ type
|
|||||||
THandleStream = class(TStream)
|
THandleStream = class(TStream)
|
||||||
private
|
private
|
||||||
FHandle: Integer;
|
FHandle: Integer;
|
||||||
protected
|
|
||||||
procedure SetSize(NewSize: Longint); override;
|
|
||||||
public
|
public
|
||||||
constructor Create(AHandle: Integer);
|
constructor Create(AHandle: Integer);
|
||||||
function Read(var Buffer; Count: Longint): Longint; override;
|
function Read(var Buffer; Count: Longint): Longint; override;
|
||||||
function Write(const Buffer; Count: Longint): Longint; override;
|
function Write(const Buffer; Count: Longint): Longint; override;
|
||||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
|
||||||
property Handle: Integer read FHandle;
|
property Handle: Integer read FHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFileStream class }
|
{ TFileStream class }
|
||||||
|
|
||||||
TFileStream = class(THandleStream)
|
TFileStream = class(THandleStream)
|
||||||
|
protected
|
||||||
|
procedure SetSize(NewSize: Longint); override;
|
||||||
public
|
public
|
||||||
constructor Create(const FileName: string; Mode: Word);
|
constructor Create(const FileName: string; Mode: Word);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCustomMemoryStream abstract class }
|
{ TCustomMemoryStream abstract class }
|
||||||
@ -1047,7 +1047,10 @@ function LineStart(Buffer, BufPos: PChar): PChar;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 1998-05-27 11:41:43 michael
|
Revision 1.5 1998-06-10 21:53:06 michael
|
||||||
|
+ Implemented Handle/FileStreams
|
||||||
|
|
||||||
|
Revision 1.4 1998/05/27 11:41:43 michael
|
||||||
Implemented TCollection and TCollectionItem
|
Implemented TCollection and TCollectionItem
|
||||||
|
|
||||||
Revision 1.3 1998/05/06 12:58:35 michael
|
Revision 1.3 1998/05/06 12:58:35 michael
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
procedure TStream.SetSize(NewSize: Longint);
|
procedure TStream.SetSize(NewSize: Longint);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SetPosition(NewSize);
|
// We do nothing. Pipe streams don't support this
|
||||||
|
// As wel as possible read-ony streams !!
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TStream.ReadBuffer(var Buffer; Count: Longint);
|
procedure TStream.ReadBuffer(var Buffer; Count: Longint);
|
||||||
@ -267,43 +268,33 @@
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
{* THandleStream *}
|
{* THandleStream *}
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
|
|
||||||
Procedure THandleStream.SetSize(NewSize: Longint);
|
|
||||||
|
|
||||||
begin
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
Constructor THandleStream.Create(AHandle: Integer);
|
Constructor THandleStream.Create(AHandle: Integer);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
FHandle:=AHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function THandleStream.Read(var Buffer; Count: Longint): Longint;
|
function THandleStream.Read(var Buffer; Count: Longint): Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Result:=OSReadHandle(FHandle,Buffer,Count);
|
||||||
|
If Result=-1 then Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function THandleStream.Write(const Buffer; Count: Longint): Longint;
|
function THandleStream.Write(const Buffer; Count: Longint): Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Result:=OSWriteHandle(FHandle,Buffer,Count);
|
||||||
|
If Result=-1 then Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function THandleStream.Seek(Offset: Longint; Origin: Word): Longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
@ -313,14 +304,36 @@ end;
|
|||||||
constructor TFileStream.Create(const FileName: string; Mode: Word);
|
constructor TFileStream.Create(const FileName: string; Mode: Word);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
FHandle:=OSCreateFile (Filename,Mode);
|
||||||
|
If FHandle<0 then
|
||||||
|
{$ifdef NoExceptions}
|
||||||
|
RunError(255);
|
||||||
|
{$else}
|
||||||
|
raise EFCreateError;
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
destructor TFileStream.Destroy;
|
destructor TFileStream.Destroy;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
OSCloseHandle(FHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TFileStream.SetSize(NewSize: Longint);
|
||||||
|
|
||||||
|
begin
|
||||||
|
OSSetHandleSize (FHandle,NewSize);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TFileStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
OSSeekHandle (FHandle,OffSet,Origin);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
{* TCustomMemoryStream *}
|
{* TCustomMemoryStream *}
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
@ -491,7 +504,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1998-05-06 12:58:35 michael
|
Revision 1.4 1998-06-10 21:53:07 michael
|
||||||
|
+ Implemented Handle/FileStreams
|
||||||
|
|
||||||
|
Revision 1.3 1998/05/06 12:58:35 michael
|
||||||
+ Added WriteAnsiString method to TStream
|
+ Added WriteAnsiString method to TStream
|
||||||
|
|
||||||
Revision 1.2 1998/05/05 15:25:04 michael
|
Revision 1.2 1998/05/05 15:25:04 michael
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# What Compiler should we use ?
|
# What Compiler should we use ?
|
||||||
PP=ppc386
|
PP=/home/michael/fpk/compiler/ppc386
|
||||||
|
|
||||||
# Where are the Free Pascal units ? (Optional)
|
# Where are the Free Pascal units ? (Optional)
|
||||||
# UNITDIR = /usr/lib/fpc/0.99.5/linuxunits
|
UNITDIR = /home/michael/fpk/rtl/linux
|
||||||
|
|
||||||
|
|
||||||
# Processor you are using
|
# Processor you are using
|
||||||
CPU=i386
|
CPU=i386
|
||||||
@ -78,7 +79,8 @@ progs: $(PROGNAMES)
|
|||||||
$(PROGNAMES): %:%.pp
|
$(PROGNAMES): %:%.pp
|
||||||
$(PP) $(OPT) $<
|
$(PP) $(OPT) $<
|
||||||
|
|
||||||
classes.ppu: classes.pp $(INCFILENAMES) $(PROCFILENAMES)
|
classes.ppu: classes.pp $(INCFILENAMES) $(PROCFILENAMES) osfile.inc \
|
||||||
|
oscalls.inc
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generic install and clean targets
|
# Generic install and clean targets
|
||||||
|
@ -28,6 +28,9 @@ uses
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{ OS-dependent file handling. }
|
||||||
|
{$i osfile.inc}
|
||||||
|
|
||||||
{ OS - independent class implementations are in /inc directory. }
|
{ OS - independent class implementations are in /inc directory. }
|
||||||
|
|
||||||
{$i classes.inc}
|
{$i classes.inc}
|
||||||
@ -35,7 +38,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1998-05-06 13:00:25 michael
|
Revision 1.4 1998-06-10 21:53:09 michael
|
||||||
|
+ Implemented Handle/FileStreams
|
||||||
|
|
||||||
|
Revision 1.3 1998/05/06 13:00:25 michael
|
||||||
+ Added strings to uses clause, for TStrings class.
|
+ Added strings to uses clause, for TStrings class.
|
||||||
|
|
||||||
Revision 1.2 1998/05/04 14:31:51 michael
|
Revision 1.2 1998/05/04 14:31:51 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user