ObjectiveLib  1.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes
OLFileInStream Class Reference

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.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
Initializers and Deallocators
(id) - initWithFileDescriptor:
 Initialize the stream.
(id) - initWithPath:
 Initialize the stream.
(void) - dealloc

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:
OLInputOutputExceptionif there is an error closing the stream

Reimplemented from OLInStream.

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
- (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:
fileDescthe 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:
OLInputOutputExceptionif a file cannot be opened with the given file name
Parameters:
paththe 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:
OLInputOutputExceptionif there is an error reading from the stream
Parameters:
bufferthe address to which the bytes should be read
maxthe 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:
OLInputOutputExceptionif a file cannot be opened with the given file name
Parameters:
paththe 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 Sat Feb 15 2014 07:45:34, © 2004-2007 Will Mason