FileHelperRK
Loading...
Searching...
No Matches
Public Member Functions
FileHelperRK::FileStreamWrite Class Reference

Class for writing to a file as a Print. More...

#include <FileHelperRK.h>

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

Public Member Functions

int open (const char *path)
 Open a file for writing. Opens as O_RDWR | O_CREAT | O_TRUNC.
 
virtual size_t write (uint8_t c)
 Writes a character to the file Override for Print pure virtual function.
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Writes multiple bytes to the file Override for Print pure virtual function.
 
- Public Member Functions inherited from FileHelperRK::FileStreamBase
 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()
 

Additional Inherited Members

- Protected Attributes inherited from FileHelperRK::FileStreamBase
int fd = -1
 File descriptor from open()
 
bool closeFile = false
 Close file on destructor.
 

Detailed Description

Class for writing to a file as a Print.

Used for writing a Variant to a file as CBOR.

Member Function Documentation

◆ open()

int FileHelperRK::FileStreamWrite::open ( const char * path)

Open a file for writing. Opens as O_RDWR | O_CREAT | O_TRUNC.

Parameters
pathFilename to write to. File will be created and truncated.
Returns
int SYSTEM_ERROR_NONE (0) on success or a system error code (non-zero)

If you want to use a different mode, call the open() method in the base class.

◆ write() [1/2]

size_t FileHelperRK::FileStreamWrite::write ( const uint8_t * buffer,
size_t size )
virtual

Writes multiple bytes to the file Override for Print pure virtual function.

Parameters
bufferPointer to a buffer of bytes to write
sizeNumber of bytes to write.
Returns
size_t Number of bytes written (normally size).

◆ write() [2/2]

size_t FileHelperRK::FileStreamWrite::write ( uint8_t c)
virtual

Writes a character to the file Override for Print pure virtual function.

Parameters
cByte to write. Can be binary data.
Returns
size_t Number of bytes written (normally 1). 0 on error.

The documentation for this class was generated from the following files: