![]() |
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Read a file on a FAT 16 or FAT 32 storage device. More...
#include <PropWare/filesystem/fat/fatfilereader.h>
Inheritance diagram for PropWare::FatFileReader:
Collaboration diagram for PropWare::FatFileReader:Public Types | |
| enum | ErrorCode { NO_ERROR = 0, BEG_ERROR = Filesystem::END_ERROR + 1, ENTRY_NOT_FILE = BEG_ERROR, FILENAME_NOT_FOUND, END_ERROR = FILENAME_NOT_FOUND } |
| enum | SeekDir { SeekDir::BEG, SeekDir::CUR, SeekDir::END } |
Public Member Functions | |
| FatFileReader (FatFS &fs, const char name[], BlockStorage::Buffer &buffer=SHARED_BUFFER, const Printer &logger=pwOut) | |
| Construct a new file instance. More... | |
| PropWare::ErrorCode | open () |
| Open the file. More... | |
| PropWare::ErrorCode | safe_get_char (char &c) |
| Read a character from the file. More... | |
| const char * | get_name () const |
| Determine the name of a file. More... | |
| bool | exists () const |
| Determine if a file exists (file does not have to be open) More... | |
| bool | exists (PropWare::ErrorCode &err) const |
| virtual PropWare::ErrorCode | close () |
| Close a file - a required step in any workflow that includes opening a file. More... | |
| virtual PropWare::ErrorCode | flush ()=0 |
| Flush any modified data back to the SD card. More... | |
| int32_t | get_length () const |
| Return the number of bytes (characters) in the file. | |
| int32_t | tell () const |
| Obtain the value of the file position indicator. More... | |
| PropWare::ErrorCode | seek (const int32_t offset, const SeekDir way) |
| Sets the position of the next character to be read or written. More... | |
| PropWare::ErrorCode | seek (const int32_t position) |
| PropWare::ErrorCode | flush () |
| Flush any modified data back to the SD card. More... | |
| char | get_char () |
| Read a character from the file. More... | |
| bool | eof () const |
| Determine whether the read pointer has reached the end of the file. More... | |
| PropWare::ErrorCode | safe_peek (char &c) |
| Read a character from the file without incrementing the pointer. More... | |
| char | peek () |
| Read a character from the file without incrementing the pointer. More... | |
| PropWare::ErrorCode | get_error () const |
| Get the latest error that occurred during an unsafe method call. More... | |
Static Public Attributes | |
| static const unsigned int | MAX_FILENAME_LENGTH = 32 |
Read a file on a FAT 16 or FAT 32 storage device.
A file can be echoed to the terminal with a simple program such as
It can also be hooked up to the PropWare::Scanner class for line-by-line or formatted reading:
Definition at line 79 of file fatfilereader.h.
|
inherited |
|
stronginherited |
| PropWare::FatFileReader::FatFileReader | ( | FatFS & | fs, |
| const char | name[], | ||
| BlockStorage::Buffer & | buffer = SHARED_BUFFER, |
||
| const Printer & | logger = pwOut |
||
| ) |
Construct a new file instance.
| [in] | fs | The filesystem is needed for opening the file |
| [in] | name | Name of the file to open - it must exist in the current working directory (see issue 55 for opening from a relative or absolute path) |
| [in] | *buffer | Address of a dedicated buffer that should be used for this file. If left as the NULL (the default), a shared buffer will be used. |
| [in] | logger | This is only used for printing debug statements. Use of the logger is limited such that all references will be optimized out in normal application code |
Definition at line 93 of file fatfilereader.h.
|
virtualinherited |
|
inherited |
Determine whether the read pointer has reached the end of the file.
Definition at line 75 of file filereader.h.
|
inherited |
|
inherited |
|
virtualinherited |
Flush any modified data back to the SD card.
Implements PropWare::File.
Definition at line 40 of file filereader.h.
|
pure virtualinherited |
Flush any modified data back to the SD card.
Implemented in PropWare::FatFileWriter, and PropWare::FileReader.
Here is the caller graph for this function:
|
virtualinherited |
Read a character from the file.
FileReader::get_error()Implements PropWare::ScanCapable.
Definition at line 60 of file filereader.h.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Get the latest error that occurred during an unsafe method call.
Methods such as FileReader::get_char() would normally throw an exception if an error occurred in a C++ program, but due to size constraints, exceptions are not used by PropWare. Therefore, any error that is occurs in a function that does not return ErrorCode simply saves the error to the internal state and returns a known value.
Definition at line 115 of file filereader.h.
|
inherited |
|
virtual |
Open the file.
Implements PropWare::File.
Definition at line 100 of file fatfilereader.h.
Here is the call graph for this function:
|
inherited |
Read a character from the file without incrementing the pointer.
FileReader::get_error()Definition at line 99 of file filereader.h.
Here is the call graph for this function:
|
virtual |
Read a character from the file.
| [out] | c | Character from file will be stored into c |
Implements PropWare::FileReader.
Definition at line 115 of file fatfilereader.h.
|
inherited |
Read a character from the file without incrementing the pointer.
| [out] | c | Character from file will be stored into c |
Definition at line 86 of file filereader.h.
Here is the call graph for this function:
|
inherited |
Sets the position of the next character to be read or written.
| [in] | offset | Offset value, relative to the way parameter |
| [in] | way | Starting position for the movement and direction of movement |
Definition at line 112 of file file.h.
Here is the caller graph for this function:
|
inherited |
|
inherited |
1.8.17