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

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.
(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.
(void) - dealloc

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

Reimplemented from OLOutStream.

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

Reimplemented from OLOutStream.

- (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:
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. 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:
OLInputOutputExceptionif a file cannot be opened with the given file name
Parameters:
paththe 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:
OLInputOutputExceptionif a file cannot be opened with the given file name
Parameters:
paththe path to the file
appendYES 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:
OLInputOutputExceptionif the path cannot be converted to a file name or if a file cannot be opened with the given file name
Parameters:
paththe 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:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
bytesthe bytes to write
countthe 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 Sat Feb 15 2014 07:45:34, © 2004-2007 Will Mason