[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LFileStream



Description:

LFileStream combines LFile and LStream into a single class. The file uess a stream to access the data fork.

This class does not provide many functions for manipulating files. You should get the FSSpec or refNum of the fork you want to manipulate and make direct calls to the Mac File Manager. However, use the member functions for opening and closing data forks.

The only file accessing functions provided are ones for reading and writing the data fork, managing the file marker and file length.

Methods :

The methods in this class are:

 

LFileStream()  
~LFileStream()  
GetLength()  
SetLength()  
GetMarker()  
SetMarker()  
GetBytes()  
PutBytes()  

Data Members:

There are no direct data members in this class

Source files:

(File & Stream Classes)

LFileStream.h

LFileStream.cp

See also:

LFile

LStream

LFileStream()

Purpose:

There are three constructor methods.

All three contructor's call the corresponding LFile construcor methods.

Access :

Public

Prototypes:

LFileStream(); // Default Constructor

LFileStream( const FSSpec &inFileSpec );

LFileStream( AliasHandle inAlias,
  Boolean& outWasChanged,
  FSSpec* inFromFile = nil);
Return:

No return value for a constructor.

Remarks:

Just calls the inherited methods.

~LFileStream()

Purpose:

The destructor closes the data and resource forks before deletion.

Access :

Public

Prototype:

virtual ~LFileStream();
Parameters:

None

Return:

No return value for a destructor

GetLength()

Purpose:

Return the length, in bytes, of the data fork of a FileStream.

Access :

Public, Virtual

Prototype:

SInt32 GetLength() const;
Parameters:

None

Return:

Size of stream in bytes.

Remarks:

Throws anexception if it fails.

SetLength()

Purpose:

Close the resource fork of a File (if any). It's a good idea to close files just after reading or writing, to avoid damage if something crashes.

Access :

Public, Virtual

Prototype:

void SetLength(SInt32 inLength);
Parameters:

 

SInt32  
inLength  
size of stream in bytes to write  

Return:

None

Remarks:

Throws an exception if it fails.

GetMarker()

Purpose:

Get the Read/Write Marker position as a byte offset from the start of the data fork stored by the Mac OS.

Access :

Virtual, Public

Prototype:

SInt32 GetMarker() const;
Parameters:

None

Return:

Offset of Maker from start of the data fork.

Remarks:

None

SetMarker()

Purpose:

Place the Read/Write Marker at an offset from a specified position. inFromWhere can be streamFrom_Start, streamFrom_End, or streamFrom_Marker.

Access :

Virtual, Public

Prototype:

void SetMarker( 
  SInt32 inOffset,
  EStreamFrom inFromWhere);
Parameters:

 

SInt32  
inOffset  
Offset position in bytes  
EStreamFrom  
inFromWhere  
Position setting  

Return:

None

Remarks:

Throws an exception if it fails.

GetBytes()

Purpose:

Reads data from the data fork of a DataStream to a buffer. Passes back the number of bytes actually read which may be less than the amount requested.

Access :

Public, Virtual

Prototype:

ExceptionCode GetBytes(
  void* outBuffer,
  SInt32& ioByteCount);
Parameters:

 

void*  
outBuffer  
Pointer to the data buffer  
SIn32&  
ioByteCount  
Number of bytes to read  

Return:

Error code providing status of the operation. noErr means operation succeded.

PutBytes()

Purpose:

Writes data from a buffer to the DataStream. Passes back the number of bytes actually written which may be less than the amount requested.

Access :

Public, Virtual

Prototype:

ExceptionCode PutBytes(
  const void* inBuffer,
  SInt32& ioByteCount);
Parameters:

 

void*  
inBuffer  
Pointer to the data buffer  
SIn32&  
ioByteCount  
Number of bytes to write  

Return:

Error code providing status of the operation. noErr means operation succeded.

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000