+ Implemented Handle/FileStreams

This commit is contained in:
michael 1998-06-10 21:53:06 +00:00
parent fee3832edb
commit 393e12a636
4 changed files with 52 additions and 25 deletions

View File

@ -458,22 +458,22 @@ type
THandleStream = class(TStream)
private
FHandle: Integer;
protected
procedure SetSize(NewSize: Longint); override;
public
constructor Create(AHandle: Integer);
function Read(var 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;
end;
{ TFileStream class }
TFileStream = class(THandleStream)
protected
procedure SetSize(NewSize: Longint); override;
public
constructor Create(const FileName: string; Mode: Word);
destructor Destroy; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
end;
{ TCustomMemoryStream abstract class }
@ -1047,7 +1047,10 @@ function LineStart(Buffer, BufPos: PChar): PChar;
{
$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
Revision 1.3 1998/05/06 12:58:35 michael

View File

@ -41,7 +41,8 @@
procedure TStream.SetSize(NewSize: Longint);
begin
SetPosition(NewSize);
// We do nothing. Pipe streams don't support this
// As wel as possible read-ony streams !!
end;
procedure TStream.ReadBuffer(var Buffer; Count: Longint);
@ -267,43 +268,33 @@
end;
{****************************************************************************}
{* THandleStream *}
{****************************************************************************}
Procedure THandleStream.SetSize(NewSize: Longint);
begin
end;
Constructor THandleStream.Create(AHandle: Integer);
begin
FHandle:=AHandle;
end;
function THandleStream.Read(var Buffer; Count: Longint): Longint;
begin
Result:=OSReadHandle(FHandle,Buffer,Count);
If Result=-1 then Result:=0;
end;
function THandleStream.Write(const Buffer; Count: Longint): Longint;
begin
Result:=OSWriteHandle(FHandle,Buffer,Count);
If Result=-1 then Result:=0;
end;
function THandleStream.Seek(Offset: Longint; Origin: Word): Longint;
begin
end;
{****************************************************************************}
@ -313,14 +304,36 @@ end;
constructor TFileStream.Create(const FileName: string; Mode: Word);
begin
FHandle:=OSCreateFile (Filename,Mode);
If FHandle<0 then
{$ifdef NoExceptions}
RunError(255);
{$else}
raise EFCreateError;
{$endif}
end;
destructor TFileStream.Destroy;
begin
OSCloseHandle(FHandle);
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 *}
{****************************************************************************}
@ -491,7 +504,10 @@ end;
{
$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
Revision 1.2 1998/05/05 15:25:04 michael

View File

@ -7,10 +7,11 @@
#
# What Compiler should we use ?
PP=ppc386
PP=/home/michael/fpk/compiler/ppc386
# 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
CPU=i386
@ -78,7 +79,8 @@ progs: $(PROGNAMES)
$(PROGNAMES): %:%.pp
$(PP) $(OPT) $<
classes.ppu: classes.pp $(INCFILENAMES) $(PROCFILENAMES)
classes.ppu: classes.pp $(INCFILENAMES) $(PROCFILENAMES) osfile.inc \
oscalls.inc
#
# Generic install and clean targets

View File

@ -28,6 +28,9 @@ uses
implementation
{ OS-dependent file handling. }
{$i osfile.inc}
{ OS - independent class implementations are in /inc directory. }
{$i classes.inc}
@ -35,7 +38,10 @@ implementation
end.
{
$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.
Revision 1.2 1998/05/04 14:31:51 michael