OLFileOutStream Class Reference
[Streams]

A connected stream that sends its data to a file. More...

#import <ObjectiveLib/FileOutStream.h>

Inheritance diagram for OLFileOutStream:

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) - flush
 Flush the stream.
(void) - freeStreamResources
 Free the stream's resources.
(unsigned) - writeBytes:count:
 Write a sequence of bytes to the stream.
Initializers and Deallocators
(id) - initWithFileDescriptor:
 Initialize the stream.
(id) - initWithPath:
 Initialize the stream.
(id) - initWithPath:append:
 Initialize the stream.

Static Public Member Functions

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

Protected Attributes

ol_fd fd
 The file descriptor of the file to which data is sent.

Detailed Description

A connected stream that sends its data to a file.

This is a concrete connected stream that is connected to a file. All data written will be sent to the file.

See also:
OLFileInStream


Member Function Documentation

- (void) close  

Close the stream.

After receiving this message the stream will no longer be available for writing.

Exceptions:
OLInputOutputException if there is an error closing the stream

Reimplemented from OLOutStream.

- (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) flush  

Flush the stream.

Any data that is pending or buffered will be written and the stream will be restored to a pristine state.

Exceptions:
OLInputOutputException if there is an error flushing the stream

Reimplemented from OLOutStream.

- (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 appended to the given file. 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. If a file already exists at the given path, then that file will be erased and a new file will written in its place.

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

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

Initialize the stream.

The stream will be created with the given file name. If a file already exists at the given path, then that file will either be truncated or appended to depending on the value of append.

Exceptions:
OLInputOutputException if a file cannot be opened with the given file name
Parameters:
path the path to the file
append YES if data should be appended to an existing file, NO if an existing file should be truncated
Returns:
a reference to this stream

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

Create and return a new file out stream.

A new stream is created with the given path. If a file already exists at the indicated path, then that file will be deleted and a new one will be created in its place.

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

- (unsigned) writeBytes: (const uint8_t *)  bytes
count: (unsigned)  count 

Write a sequence of bytes to the stream.

As many bytes up to the value of count will be written to the file, and the actual number written will be returned.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
bytes the bytes to write
count the number of bytes to write
Returns:
the number of bytes written

Reimplemented from OLOutStream.


Member Data Documentation

- (ol_fd) fd [protected]

The file descriptor of the file to which data is sent.


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