FileHelperRK
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
FileHelperRK::FileStreamBase Class Reference

Class for providing Stream and Print object for reading or writing a file. More...

#include <FileHelperRK.h>

Inheritance diagram for FileHelperRK::FileStreamBase:
FileHelperRK::FileStreamRead FileHelperRK::FileStreamWrite

Public Member Functions

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

Protected Attributes

int fd = -1
 File descriptor from open()
 
bool closeFile = false
 Close file on destructor.
 

Detailed Description

Class for providing Stream and Print object for reading or writing a file.

Important limitations:

Constructor & Destructor Documentation

◆ FileStreamBase()

FileHelperRK::FileStreamBase::FileStreamBase ( int fd)

Construct object from an existing file descriptor from open()

Parameters
fdFile 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.

Member Function Documentation

◆ 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
pathFilename to open.
modeMode such as O_RDONLY, or O_RDWR | O_CREAT | O_TRUNC.
permPermissions, 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: