PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Public Types | Public Member Functions | Static Public Attributes | List of all members
PropWare::FileWriter Class Referenceabstract

A write-only file interface. More...

#include <PropWare/filesystem/filewriter.h>

+ Inheritance diagram for PropWare::FileWriter:
+ Collaboration diagram for PropWare::FileWriter:

Public Types

enum  ErrorCode {
  NO_ERROR = 0,
  BEG_ERROR = Filesystem::BEG_ERROR + 1,
  EOF_ERROR,
  INVALID_FILENAME,
  FILE_NOT_OPEN,
  END_ERROR = FILE_NOT_OPEN
}
 
enum  SeekDir {
  SeekDir::BEG,
  SeekDir::CUR,
  SeekDir::END
}
 

Public Member Functions

 FileWriter (Filesystem &fs, const char name[], BlockStorage::Buffer buffer, const Printer &logger=pwOut)
 
virtual PropWare::ErrorCode safe_put_char (const char c)=0
 Write a character to the file. More...
 
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
 
virtual PropWare::ErrorCode open ()=0
 Open the file. More...
 
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)
 

Static Public Attributes

static const unsigned int MAX_FILENAME_LENGTH = 32
 

Detailed Description

A write-only file interface.

Definition at line 36 of file filewriter.h.

Member Enumeration Documentation

◆ ErrorCode

enum PropWare::File::ErrorCode
inherited
Enumerator
NO_ERROR 

Successful completion

BEG_ERROR 

First error code

EOF_ERROR 

End of file

INVALID_FILENAME 

Invalid file name

FILE_NOT_OPEN 

File not opened

END_ERROR 

Final error code

Definition at line 38 of file file.h.

◆ SeekDir

enum PropWare::File::SeekDir
stronginherited
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.

Member Function Documentation

◆ 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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush()

virtual PropWare::ErrorCode PropWare::File::flush ( )
pure virtualinherited

Flush any modified data back to the SD card.

Returns
0 upon success, error code otherwise

Implemented in PropWare::FatFileWriter, and PropWare::FileReader.

+ Here is the caller graph for this function:

◆ open()

virtual PropWare::ErrorCode PropWare::File::open ( )
pure virtualinherited

Open the file.

Returns
0 upon success, error code otherwise

Implemented in PropWare::FatFileReader, and PropWare::FatFileWriter.

◆ put_char()

void PropWare::FileWriter::put_char ( const char  c)
virtual

Write a character to the file.

Parameters
[in]cCharacter that should be written

Implements PropWare::PrintCapable.

Definition at line 57 of file filewriter.h.

+ Here is the call graph for this function:

◆ puts()

void PropWare::FileWriter::puts ( const char  string[])
virtual

Write a character array to the file.

Parameters
[in]stringNull-terminated character array that should be written

Implements PropWare::PrintCapable.

Definition at line 85 of file filewriter.h.

+ Here is the call graph for this function:

◆ safe_put_char()

virtual PropWare::ErrorCode PropWare::FileWriter::safe_put_char ( const char  c)
pure virtual

Write a character to the file.

Parameters
[in]cCharacter that should be written
Returns
0 upon success, error code otherwise

Implemented in PropWare::FatFileWriter.

+ Here is the caller graph for this function:

◆ safe_puts()

virtual PropWare::ErrorCode PropWare::FileWriter::safe_puts ( const char  string[])
virtual

Write a character array to the file.

Parameters
[in]stringNull-terminated character array that should be written
Returns
0 upon success, error code otherwise

Definition at line 68 of file filewriter.h.

+ Here is the caller graph for this function:

◆ 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]offsetOffset value, relative to the way parameter
[in]wayStarting position for the movement and direction of movement
Returns
0 upon success, error code otherwise

Definition at line 112 of file file.h.

+ Here is the caller graph for this function:

◆ 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]positionAbsolute position to move the file position indicator

Definition at line 147 of file file.h.

+ Here is the call graph for this function:

◆ 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: