OLFileInStream Class Reference
[Streams]

A connected stream that reads its data from a file. More...

#import <ObjectiveLib/FileInStream.h>

Inheritance diagram for OLFileInStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - close
 Close the stream.
(ol_fd- fileDescriptor
 Return the file descriptor associated with the file stream.
(void) - freeStreamResources
 Free the stream's resources.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
Initializers and Deallocators
(id) - initWithFileDescriptor:
 Initialize the stream.
(id) - initWithPath:
 Initialize the stream.

Static Public Member Functions

(id) + streamWithPath:
 Create and return a new file in stream.

Protected Attributes

ol_fd fd
 The file descriptor of the file from which data is read.

Detailed Description

A connected stream that reads its data from a file.

This is a concrete connected stream that is connected to a file.

See also:
OLFileOutStream


Member Function Documentation

- (void) close  

Close the stream.

After receiving this message the stream will no long be available for reading.

Exceptions:
OLInputOutputException if there is an error closing the stream

Reimplemented from OLInStream.

- (ol_fd) fileDescriptor  

Return the file descriptor associated with the file stream.

Note:
The file stream always owns the file descriptor, so one should never close a file descriptor that is already associated with a file stream.
Returns:
the file descriptor

- (void) freeStreamResources  

Free the stream's resources.

This secondary freeing method is necessary to allow the reference count to be properly manipulated from within the normal free (OLReferenceCountedStream) method.

Note:
All sublcasses that allocate resources must implement this method to free those resources and call [super freeStreamResources].

Reimplemented from OLReferenceCountedStream.

- (id) initWithFileDescriptor: (ol_fd fileDesc  

Initialize the stream.

The stream will be created with the given file descriptor and all new data will be read starting from the file's current position. The stream will take ownership of the file descriptor and will assume that the stream is responsible for closing the file descriptor.

Parameters:
fileDesc the file descriptor of the file to which to write
Returns:
a reference to this stream

- (id) initWithPath: (const char *)  path  

Initialize the stream.

The stream will be created with the given file name.

Exceptions:
OLInputOutputException if a file cannot be opened with the given file name
Parameters:
path the path to the file
Returns:
a reference to this stream

- (unsigned) readBytes: (uint8_t *)  buffer
count: (unsigned)  max 

Read a sequence of bytes from the stream.

Bytes up to the amount of max are read from the file. The number of bytes read is returned except in the case where the end of the file has been reached. Rather than raising an exception in this case, this method returns UINT_MAX.

Exceptions:
OLInputOutputException if there is an error reading from the stream
Parameters:
buffer the address to which the bytes should be read
max the maximum number bytes that should be read
Returns:
the number of bytes read or UINT_MAX if no bytes could be read

Reimplemented from OLInStream.

+ (id) streamWithPath: (const char *)  path  

Create and return a new file in stream.

A new stream is created with the given path.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Exceptions:
OLInputOutputException if a file cannot be opened with the given file name
Parameters:
path the path
Returns:
a reference to theh newly created stream


Member Data Documentation

- (ol_fd) fd [protected]

The file descriptor of the file from which data is read.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:18:28 2007, © 2004-2007 Will Mason
SourceForge.net Logo