Prusa3d Marlin fork
Public Member Functions | List of all members
SdFile Class Reference

SdBaseFile with Print.

#include <SdFile.h>

Inheritance diagram for SdFile:
Inheritance graph
[legend]
Collaboration diagram for SdFile:
Collaboration graph
[legend]

Public Member Functions

 SdFile (const char *name, uint8_t oflag)
 
size_t write (uint8_t b)
 
void write (uint8_t b)
 
bool openFilteredGcode (SdBaseFile *dirFile, const char *path)
 
int16_t readFilteredGcode ()
 
bool seekSetFilteredGcode (uint32_t pos)
 
int16_t write (const void *buf, uint16_t nbyte)
 
void write (const char *str)
 
void write_P (PGM_P str)
 
void writeln_P (PGM_P str)
 
- Public Member Functions inherited from SdBaseFile
 SdBaseFile ()
 
 SdBaseFile (const char *path, uint8_t oflag)
 
void getpos (filepos_t *pos)
 
void setpos (filepos_t *pos)
 
bool close ()
 
bool contiguousRange (uint32_t *bgnBlock, uint32_t *endBlock)
 
bool createContiguous (SdBaseFile *dirFile, const char *path, uint32_t size)
 
uint32_t curCluster () const
 
uint32_t curPosition () const
 
bool dirEntry (dir_t *dir)
 
bool exists (const char *name)
 
int16_t fgets (char *str, int16_t num, char *delim=0)
 
uint32_t fileSize () const
 
uint32_t firstCluster () const
 
bool getFilename (char *name)
 
bool isDir () const
 
bool isFile () const
 
bool isOpen () const
 
bool isSubDir () const
 
bool isRoot () const
 
void ls (uint8_t flags=0, uint8_t indent=0)
 
bool mkdir (SdBaseFile *dir, const char *path, bool pFlag=true)
 
bool makeDir (SdBaseFile *dir, const char *path)
 
bool open (SdBaseFile *dirFile, uint16_t index, uint8_t oflag)
 
bool open (SdBaseFile *dirFile, const char *path, uint8_t oflag)
 
bool open (const char *path, uint8_t oflag=O_READ)
 
bool openNext (SdBaseFile *dirFile, uint8_t oflag)
 
bool openRoot (SdVolume *vol)
 
int peek ()
 
bool printName ()
 
int8_t readDir (dir_t *dir, char *longFilename)
 
bool remove ()
 
void rewind ()
 
bool rename (SdBaseFile *dirFile, const char *newPath)
 
bool rmdir ()
 
bool rmDir ()
 
bool rmRfStar ()
 
bool seekCur (int32_t offset)
 
bool seekEnd (int32_t offset=0)
 
bool seekSet (uint32_t pos)
 
bool sync ()
 
bool timestamp (SdBaseFile *file)
 
bool timestamp (uint8_t flag, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
 
uint8_t type () const
 
bool truncate (uint32_t size)
 
SdVolumevolume () const
 
int16_t write (const void *buf, uint16_t nbyte)
 
bool contiguousRange (uint32_t &bgnBlock, uint32_t &endBlock)
 
bool createContiguous (SdBaseFile &dirFile, const char *path, uint32_t size)
 
bool dirEntry (dir_t &dir)
 
bool mkdir (SdBaseFile &dir, const char *path)
 
bool open (SdBaseFile &dirFile, const char *path, uint8_t oflag)
 
bool open (SdBaseFile &dirFile, const char *path)
 
bool open (SdBaseFile &dirFile, uint16_t index, uint8_t oflag)
 
bool openRoot (SdVolume &vol)
 
int8_t readDir (dir_t &dir, char *longFilename)
 

Additional Inherited Members

- Static Public Member Functions inherited from SdBaseFile
static SdBaseFilecwd ()
 
static void dateTimeCallback (void(*dateTime)(uint16_t *date, uint16_t *time))
 
static void dateTimeCallbackCancel ()
 
static void dirName (const dir_t &dir, char *name)
 
static void printFatDate (uint16_t fatDate)
 
static void printFatTime (uint16_t fatTime)
 
static bool remove (SdBaseFile *dirFile, const char *path)
 
static void dateTimeCallback (void(*dateTime)(uint16_t &date, uint16_t &time))
 
static bool remove (SdBaseFile &dirFile, const char *path)
 
- Public Attributes inherited from SdBaseFile
bool writeError
 
- Protected Member Functions inherited from SdBaseFile
int16_t read ()
 
int16_t read (void *buf, uint16_t nbyte)
 
bool openParent (SdBaseFile *dir)
 
bool addCluster ()
 
bool addDirCluster ()
 
dir_tcacheDirEntry (uint8_t action)
 
int8_t lsPrintNext (uint8_t flags, uint8_t indent)
 
bool mkdir (SdBaseFile *parent, const uint8_t dname[11])
 
bool open (SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag)
 
bool openCachedEntry (uint8_t cacheIndex, uint8_t oflags)
 
dir_treadDirCache ()
 
- Static Protected Member Functions inherited from SdBaseFile
static bool make83Name (const char *str, uint8_t *name, const char **ptr)
 
static void printDirName (const dir_t &dir, uint8_t width, bool printSlash)
 
- Protected Attributes inherited from SdBaseFile
uint8_t flags_
 
uint8_t fstate_
 
uint8_t type_
 
uint32_t curCluster_
 
uint32_t curPosition_
 
uint32_t dirBlock_
 
uint8_t dirIndex_
 
uint32_t fileSize_
 
uint32_t firstCluster_
 
SdVolumevol_
 
- Static Protected Attributes inherited from SdBaseFile
static SdBaseFilecwd_ = 0
 
static void(* dateTime_ )(uint16_t *date, uint16_t *time)
 
static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC)
 
static uint8_t const F_FILE_DIR_DIRTY = 0X80
 

Constructor & Destructor Documentation

◆ SdFile()

SdFile::SdFile ( const char *  path,
uint8_t  oflag 
)

Create a file object and open it in the current working directory.

Parameters
[in]pathA path with a valid 8.3 DOS name for a file to be opened.
[in]oflagValues for oflag are constructed by a bitwise-inclusive OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t).

Member Function Documentation

◆ write() [1/3]

void SdFile::write ( const char *  str)

Write a string to a file. Used by the Arduino Print class.

Parameters
[in]strPointer to the string. Use writeError to check for errors.

◆ write() [2/3]

int16_t SdFile::write ( const void *  buf,
uint16_t  nbyte 
)

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]bufPointer to the location of the data to be written.
[in]nbyteNumber of bytes to write.
Returns
For success write() returns the number of bytes written, always nbyte. If an error occurs, write() returns -1. Possible errors include write() is called before a file has been opened, write is called for a read-only file, device is full, a corrupt file system or an I/O error.

◆ write() [3/3]

void SdFile::write ( uint8_t  b)

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

Parameters
[in]bthe byte to be written. Use writeError to check for errors.

◆ write_P()

void SdFile::write_P ( PGM_P  str)

Write a PROGMEM string to a file.

Parameters
[in]strPointer to the PROGMEM string. Use writeError to check for errors.

◆ writeln_P()

void SdFile::writeln_P ( PGM_P  str)

Write a PROGMEM string followed by CR/LF to a file.

Parameters
[in]strPointer to the PROGMEM string. Use writeError to check for errors.

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