SdFat
Public Member Functions | List of all members
StreamFile< BaseFile, PosType > Class Template Reference

StreamFile class. More...

#include <ArduinoFiles.h>

Inheritance diagram for StreamFile< BaseFile, PosType >:
Inheritance graph
[legend]
Collaboration diagram for StreamFile< BaseFile, PosType >:
Collaboration graph
[legend]

Public Member Functions

int available ()
 
void flush ()
 
bool isDirectory ()
 
const char * name () const
 
int peek ()
 
PosType position ()
 
int read ()
 
void rewindDirectory ()
 
bool seek (PosType pos)
 
PosType size ()
 
size_t write (const uint8_t *buffer, size_t size)
 
size_t write (uint8_t b)
 

Detailed Description

template<class BaseFile, typename PosType>
class StreamFile< BaseFile, PosType >

StreamFile class.

Member Function Documentation

◆ available()

template<class BaseFile, typename PosType>
int StreamFile< BaseFile, PosType >::available ( )
inline
Returns
number of bytes available from the current position to EOF or INT_MAX if more than INT_MAX bytes are available.

◆ flush()

template<class BaseFile, typename PosType>
void StreamFile< BaseFile, PosType >::flush ( )
inline

Ensure that any bytes written to the file are saved to the SD card.

◆ isDirectory()

template<class BaseFile, typename PosType>
bool StreamFile< BaseFile, PosType >::isDirectory ( )
inline

This function reports if the current file is a directory or not.

Returns
true if the file is a directory.

◆ name()

template<class BaseFile, typename PosType>
const char* StreamFile< BaseFile, PosType >::name ( ) const
inline

No longer implemented due to Long File Names.

Use getName(char* name, size_t size).

Returns
a pointer to replacement suggestion.

◆ peek()

template<class BaseFile, typename PosType>
int StreamFile< BaseFile, PosType >::peek ( )
inline

Return the next available byte without consuming it.

Returns
The byte if no error and not at eof else -1;

◆ position()

template<class BaseFile, typename PosType>
PosType StreamFile< BaseFile, PosType >::position ( )
inline
Returns
the current file position.

◆ read()

template<class BaseFile, typename PosType>
int StreamFile< BaseFile, PosType >::read ( )
inline

Read the next byte from a file.

Returns
For success return the next byte in the file as an int. If an error occurs or end of file is reached return -1.

◆ rewindDirectory()

template<class BaseFile, typename PosType>
void StreamFile< BaseFile, PosType >::rewindDirectory ( )
inline

Rewind a file if it is a directory

◆ seek()

template<class BaseFile, typename PosType>
bool StreamFile< BaseFile, PosType >::seek ( PosType  pos)
inline

Seek to a new position in the file, which must be between 0 and the size of the file (inclusive).

Parameters
[in]posthe new file position.
Returns
true for success or false for failure.

◆ size()

template<class BaseFile, typename PosType>
PosType StreamFile< BaseFile, PosType >::size ( )
inline
Returns
the file's size.

◆ write() [1/2]

template<class BaseFile, typename PosType>
size_t StreamFile< BaseFile, PosType >::write ( const uint8_t *  buffer,
size_t  size 
)
inline

Write data to an open file.

Note
Data is moved to the cache but may not be written to the storage device until sync() is called.
Parameters
[in]bufferPointer to the location of the data to be written.
[in]sizeNumber of bytes to write.
Returns
For success write() returns the number of bytes written, always size.

◆ write() [2/2]

template<class BaseFile, typename PosType>
size_t StreamFile< BaseFile, PosType >::write ( uint8_t  b)
inline

Write a byte to a file. Required by the Arduino Print class.

Parameters
[in]bthe byte to be written. Use getWriteError to check for errors.
Returns
1 for success and 0 for failure.

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