Class for providing Stream and Print object for reading or writing a file.
More...
#include <FileHelperRK.h>
|
| FileStreamBase () |
| Construct object; you will typically do this and then call openForReading or openForWriting.
|
|
| FileStreamBase (int fd) |
| Construct object from an existing file descriptor from open()
|
|
virtual | ~FileStreamBase () |
| Destructor.
|
|
int | open (const char *path, int mode, int perm=0666) |
| Open a file.
|
|
int | close () |
| Close the underling file if it was opened using open()
|
|
|
int | fd = -1 |
| File descriptor from open()
|
|
bool | closeFile = false |
| Close file on destructor.
|
|
Class for providing Stream and Print object for reading or writing a file.
Important limitations:
- This class is only for reading or writing, not both at the same time
- When reading from a stream, the underling file is not expected to change; it cannot be used for live tail for example
◆ FileStreamBase()
FileHelperRK::FileStreamBase::FileStreamBase |
( |
int | fd | ) |
|
Construct object from an existing file descriptor from open()
- Parameters
-
fd | File descriptor from open(). Will not be closed on destruction. |
◆ ~FileStreamBase()
FileHelperRK::FileStreamBase::~FileStreamBase |
( |
| ) |
|
|
virtual |
Destructor.
If file was opened using openForReading(), openForWriting(), or open() and close() has not been called, the file will be closed when the object is deleted.
◆ close()
int FileHelperRK::FileStreamBase::close |
( |
| ) |
|
Close the underling file if it was opened using open()
- Returns
- int SYSTEM_ERROR_NONE (0) on success or a system error code (non-zero)
If you don't call close(), the file will be closed on object destruction if it was opened.
◆ open()
int FileHelperRK::FileStreamBase::open |
( |
const char * | path, |
|
|
int | mode, |
|
|
int | perm = 0666 ) |
Open a file.
- Parameters
-
path | Filename to open. |
mode | Mode such as O_RDONLY, or O_RDWR | O_CREAT | O_TRUNC. |
perm | Permissions, defaults to 0666 (read and write for everyone). |
- Returns
- int SYSTEM_ERROR_NONE (0) on success or a system error code (non-zero)
The documentation for this class was generated from the following files: