blocxx
|
The purpose of this class is to provide an alternative implementation of std::ifstream that is based on a FILE*, and can be created using a FILE*, a raw file descriptor or an instance of blocxx::File. More...
#include <IFileStream.hpp>
Public Member Functions | |
IFileStream () | |
Constructor. | |
~IFileStream () | |
Calls close(). | |
bool | isOpen () const |
IFileStream * | open (FILE *fp) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp. | |
IFileStream * | open (AutoDescriptor fd) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd. | |
IFileStream * | open (const char *path, std::ios_base::openmode mode, mode_t permissions=0666) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream by opening the file identified by path. | |
IFileStream * | close () |
If isOpen() == false, returns a null pointer. | |
Private Member Functions | |
IFileStream (const IFileStream &arg) | |
IFileStream & | operator= (const IFileStream &arg) |
The purpose of this class is to provide an alternative implementation of std::ifstream that is based on a FILE*, and can be created using a FILE*, a raw file descriptor or an instance of blocxx::File.
IFileStream does not support all the operations that a std::ifstream does. IFileStream does not support seeking, character putback, facets, i18n. Basically all it does support is reading.
Definition at line 57 of file IFileStream.hpp.
usr src packages BUILD blocxx src blocxx IFileStream cpp BLOCXX_NAMESPACE::IFileStream::IFileStream | ( | ) |
BLOCXX_NAMESPACE::IFileStream::~IFileStream | ( | ) |
Calls close().
Definition at line 54 of file IFileStream.cpp.
BLOCXX_NAMESPACE::IFileStream::IFileStream | ( | const IFileStream & | arg | ) | [private] |
IFileStream * BLOCXX_NAMESPACE::IFileStream::close | ( | ) |
If isOpen() == false, returns a null pointer.
If a put area exists, calls overflow(EOF) to flush characters. Finally it closes the file. If any of the calls to overflow or std::fclose fails then close fails.
Reimplemented from BLOCXX_NAMESPACE::FileBuf.
Definition at line 95 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::close().
bool BLOCXX_NAMESPACE::IFileStream::isOpen | ( | ) | const |
Reimplemented from BLOCXX_NAMESPACE::FileBuf.
Definition at line 59 of file IFileStream.cpp.
IFileStream * BLOCXX_NAMESPACE::IFileStream::open | ( | FILE * | fp | ) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp.
fp | The FILE* to use. The IFileStream will take ownership of fp, so close() will call std::fclose() on fp. |
Reimplemented from BLOCXX_NAMESPACE::FileBuf.
Definition at line 65 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open().
IFileStream * BLOCXX_NAMESPACE::IFileStream::open | ( | const char * | path, |
std::ios_base::openmode | mode, | ||
mode_t | permissions = 0666 |
||
) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream by opening the file identified by path.
If the open operation succeeds and (mode & ios_base::ate) != 0, positions the file to the end. If the repositioning operation fails, calls close() and returns a null pointer to indicate failure.
path | A null-terminated string identifying the file to open. |
mode | A bitmask of the file open mode flags defined in ios_base. Invalid combinations cause the operation to fail. |
permissions | Specifies the permissions to use in case a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). Note that this mode only applies to future accesses of the newly created file; the open call that creates a read-only file may well return a read/write file descriptor. |
Reimplemented from BLOCXX_NAMESPACE::FileBuf.
Definition at line 85 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open().
IFileStream * BLOCXX_NAMESPACE::IFileStream::open | ( | AutoDescriptor | fd | ) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd.
fd | The descriptor to use. The IFileStream will take ownership of fd, so close() will close the descriptor. |
Reimplemented from BLOCXX_NAMESPACE::FileBuf.
Definition at line 75 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open().
IFileStream& BLOCXX_NAMESPACE::IFileStream::operator= | ( | const IFileStream & | arg | ) | [private] |