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:
Data Members:
There are no direct data members in this class
Source files:
See also:
Purpose:
There are three constructor methods.
All three contructor's call the corresponding LFile construcor methods.
Access :
Prototypes:
LFileStream(); // Default Constructor
LFileStream( const FSSpec &inFileSpec );
LFileStream( AliasHandle inAlias,
Boolean& outWasChanged, FSSpec* inFromFile = nil); No return value for a constructor.
Remarks:
Just calls the inherited methods.
Purpose:
The destructor closes the data and resource forks before deletion.
Access :
Prototype:
virtual ~LFileStream();Parameters:
Return:
No return value for a destructor
Purpose:
Return the length, in bytes, of the data fork of a FileStream.
Access :
Prototype:
SInt32 GetLength() const;Parameters:
Return:
Remarks:
Throws anexception if it fails.
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 :
Prototype:
void SetLength(SInt32 inLength);Parameters:
Return:
Remarks:
Throws an exception if it fails.
Purpose:
Get the Read/Write Marker position as a byte offset from the start of the data fork stored by the Mac OS.
Access :
Prototype:
SInt32 GetMarker() const;Parameters:
Return:
Offset of Maker from start of the data fork.
Remarks:
Purpose:
Place the Read/Write Marker at an offset from a specified position.
inFromWhere can be streamFrom_Start, streamFrom_End, or streamFrom_Marker.
Access :
Prototype:
void SetMarker(
SInt32 inOffset, EStreamFrom inFromWhere); Return:
Remarks:
Throws an exception if it fails.
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 :
Prototype:
ExceptionCode GetBytes(
void* outBuffer, SInt32& ioByteCount); Return:
Error code providing status of the operation. noErr means operation succeded.
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 :
Prototype:
ExceptionCode PutBytes(
const void* inBuffer, SInt32& ioByteCount); Return:
Error code providing status of the operation. noErr means operation succeded.