Concrete class for writing or modifying a FAT 16/32 file.
More...
#include <PropWare/filesystem/fat/fatfilewriter.h>
|
| FatFileWriter (FatFS &fs, const char name[], BlockStorage::Buffer &buffer=SHARED_BUFFER, const Printer &logger=pwOut) |
| Standard constructor. More...
|
|
virtual | ~FatFileWriter () |
| All content will be saved to the physical device and the file will be safely closed.
|
|
PropWare::ErrorCode | open () |
| Open the file. More...
|
|
PropWare::ErrorCode | remove () |
| Mark a file as delete and free its clusters in the FAT. File content will not be cleared unless overwritten by another file. File does not have to be opened prior to deleting.
|
|
PropWare::ErrorCode | flush () |
| Flush any modified data back to the SD card. More...
|
|
PropWare::ErrorCode | safe_put_char (const char c) |
| Write a character to the file. More...
|
|
void | print_status (const bool printBlocks=false) const |
|
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...
|
|
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) |
|
void | put_char (const char c) |
| Write a character to the file. More...
|
|
virtual PropWare::ErrorCode | safe_puts (const char string[]) |
| Write a character array to the file. More...
|
|
void | puts (const char string[]) |
| Write a character array to the file. More...
|
|
void | print_status (const bool printBlocks=false, const bool printParentStatus=true) const |
|
|
static const unsigned int | MAX_FILENAME_LENGTH = 32 |
|
Concrete class for writing or modifying a FAT 16/32 file.
- Examples
- FileWriter_Demo.cpp.
Definition at line 38 of file fatfilewriter.h.
◆ ErrorCode
◆ SeekDir
Enumerator |
---|
BEG | beginning of the stream
|
CUR | current position in the stream
|
END | end of the stream
|
Definition at line 47 of file file.h.
◆ FatFileWriter()
Standard constructor.
- Parameters
-
[in] | fs | A mounted FAT 16/32 filesystem |
[in] | name[] | Character array with the file name |
[in] | *buffer | If you don't want to use the globally shared buffer, a different buffer address can be provided here |
[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 51 of file fatfilewriter.h.
◆ close()
virtual PropWare::ErrorCode PropWare::File::close |
( |
| ) |
|
|
virtualinherited |
Close a file - a required step in any workflow that includes opening a file.
- Returns
- 0 upon success, error code otherwise
Definition at line 74 of file file.h.
◆ exists() [1/2]
bool PropWare::FatFile::exists |
( |
| ) |
const |
|
inherited |
Determine if a file exists (file does not have to be open)
- Returns
- True if the file exists, false otherwise
Definition at line 62 of file fatfile.h.
◆ exists() [2/2]
bool PropWare::FatFile::exists |
( |
PropWare::ErrorCode & |
err | ) |
const |
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
[out] | err | It is possible for an error to occur |
Definition at line 72 of file fatfile.h.
◆ flush()
PropWare::ErrorCode PropWare::FatFileWriter::flush |
( |
| ) |
|
|
virtual |
◆ get_name()
const char* PropWare::FatFile::get_name |
( |
| ) |
const |
|
inherited |
Determine the name of a file.
- Returns
- Character array containing the file - DO NOT modify the array, it will modify the internals of the file instance
Definition at line 53 of file fatfile.h.
◆ open()
PropWare::ErrorCode PropWare::FatFileWriter::open |
( |
| ) |
|
|
virtual |
◆ put_char()
void PropWare::FileWriter::put_char |
( |
const char |
c | ) |
|
|
virtualinherited |
◆ puts()
void PropWare::FileWriter::puts |
( |
const char |
string[] | ) |
|
|
virtualinherited |
Write a character array to the file.
- Parameters
-
[in] | string | Null-terminated character array that should be written |
Implements PropWare::PrintCapable.
Definition at line 85 of file filewriter.h.
◆ safe_put_char()
PropWare::ErrorCode PropWare::FatFileWriter::safe_put_char |
( |
const char |
c | ) |
|
|
virtual |
Write a character to the file.
- Parameters
-
[in] | c | Character that should be written |
- Returns
- 0 upon success, error code otherwise
Implements PropWare::FileWriter.
Definition at line 142 of file fatfilewriter.h.
◆ safe_puts()
virtual PropWare::ErrorCode PropWare::FileWriter::safe_puts |
( |
const char |
string[] | ) |
|
|
virtualinherited |
Write a character array to the file.
- Parameters
-
[in] | string | Null-terminated character array that should be written |
- Returns
- 0 upon success, error code otherwise
Definition at line 68 of file filewriter.h.
◆ seek() [1/2]
PropWare::ErrorCode PropWare::File::seek |
( |
const int32_t |
offset, |
|
|
const SeekDir |
way |
|
) |
| |
|
inherited |
Sets the position of the next character to be read or written.
- Parameters
-
[in] | offset | Offset value, relative to the way parameter |
[in] | way | Starting position for the movement and direction of movement |
- Returns
- 0 upon success, error code otherwise
Definition at line 112 of file file.h.
◆ seek() [2/2]
PropWare::ErrorCode PropWare::File::seek |
( |
const int32_t |
position | ) |
|
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
[in] | position | Absolute position to move the file position indicator |
Definition at line 147 of file file.h.
◆ tell()
int32_t PropWare::File::tell |
( |
| ) |
const |
|
inherited |
Obtain the value of the file position indicator.
- Postcondition
- The next byte to be read from the file
Definition at line 100 of file file.h.
The documentation for this class was generated from the following file: