Prusa MINI Firmware overview
|
Base class for SdFile with Print and C++ streams.
More...
#include <SdBaseFile.h>
|
| SdBaseFile () |
|
| SdBaseFile (const char *path, uint8_t oflag) |
|
| ~SdBaseFile () |
|
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 | isDir () const |
|
bool | isFile () const |
|
bool | isOpen () const |
|
bool | isSubDir () const |
|
bool | isRoot () const |
|
bool | getDosName (char *const name) |
|
void | ls (uint8_t flags=0, uint8_t indent=0) |
|
bool | mkdir (SdBaseFile *dir, const char *path, bool pFlag=true) |
|
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 () |
|
int16_t | read () |
|
int16_t | read (void *buf, uint16_t nbyte) |
|
int8_t | readDir (dir_t *dir, char *longFilename) |
|
bool | remove () |
|
void | rewind () |
|
bool | rename (SdBaseFile *dirFile, const char *newPath) |
|
bool | rmdir () |
|
bool | rmRfStar () |
|
bool | seekCur (const int32_t offset) |
|
bool | seekEnd (const int32_t offset=0) |
|
bool | seekSet (const 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) |
|
SdVolume * | volume () const |
|
int16_t | write (const void *buf, uint16_t nbyte) |
|
Base class for SdFile with Print and C++ streams.
◆ SdBaseFile() [1/2]
SdBaseFile::SdBaseFile |
( |
| ) |
|
◆ SdBaseFile() [2/2]
◆ ~SdBaseFile()
SdBaseFile::~SdBaseFile |
( |
| ) |
|
◆ getpos()
get position for streams
- Parameters
-
[out] | pos | struct to receive position |
◆ setpos()
set position for streams
- Parameters
-
[out] | pos | struct with value for new position |
◆ close()
bool SdBaseFile::close |
( |
| ) |
|
537 bool success =
false;
◆ contiguousRange()
bool SdBaseFile::contiguousRange |
( |
uint32_t * |
bgnBlock, |
|
|
uint32_t * |
endBlock |
|
) |
| |
◆ createContiguous()
bool SdBaseFile::createContiguous |
( |
SdBaseFile * |
dirFile, |
|
|
const char * |
path, |
|
|
uint32_t |
size |
|
) |
| |
◆ curCluster()
uint32_t SdBaseFile::curCluster |
( |
| ) |
const |
- Returns
- The current cluster number for a file or directory.
200 {
return curCluster_; }
◆ curPosition()
uint32_t SdBaseFile::curPosition |
( |
| ) |
const |
- Returns
- The current position for a file or directory.
205 {
return curPosition_; }
◆ cwd()
- Returns
- Current working directory
◆ dateTimeCallback()
static void SdBaseFile::dateTimeCallback |
( |
void(*)(uint16_t *date, uint16_t *time) |
dateTime | ) |
|
|
static |
Set the date/time callback function
- Parameters
-
[in] | dateTime | The user's call back function. The callback function is of the form: |
void dateTime(uint16_t* date, uint16_t* time) {
uint16_t year;
uint8_t month, day, hour, minute, second;
}
Sets the function that is called when a file is created or when a file's directory entry is modified by sync(). All timestamps, access, creation, and modify, are set when a file is created. sync() maintains the last access date and last modify date/time.
See the timestamp() function.
242 dateTime_ = dateTime;
◆ dateTimeCallbackCancel()
static void SdBaseFile::dateTimeCallbackCancel |
( |
| ) |
|
|
static |
Cancel the date/time callback function.
◆ dirEntry()
bool SdBaseFile::dirEntry |
( |
dir_t * |
dir | ) |
|
◆ dirName()
◆ exists()
bool SdBaseFile::exists |
( |
const char * |
name | ) |
|
◆ fgets()
int16_t SdBaseFile::fgets |
( |
char * |
str, |
|
|
int16_t |
num, |
|
|
char * |
delim = 0 |
|
) |
| |
◆ fileSize()
uint32_t SdBaseFile::fileSize |
( |
| ) |
const |
- Returns
- The total number of bytes in a file or directory.
257 {
return fileSize_; }
◆ firstCluster()
uint32_t SdBaseFile::firstCluster |
( |
| ) |
const |
- Returns
- The first cluster number for a file or directory.
262 {
return firstCluster_; }
◆ isDir()
bool SdBaseFile::isDir |
( |
| ) |
const |
- Returns
- True if this is a directory else false.
◆ isFile()
bool SdBaseFile::isFile |
( |
| ) |
const |
- Returns
- True if this is a normal file else false.
◆ isOpen()
bool SdBaseFile::isOpen |
( |
| ) |
const |
- Returns
- True if this is an open file/directory else false.
◆ isSubDir()
bool SdBaseFile::isSubDir |
( |
| ) |
const |
- Returns
- True if this is a subdirectory else false.
◆ isRoot()
bool SdBaseFile::isRoot |
( |
| ) |
const |
- Returns
- True if this is the root directory.
◆ getDosName()
bool SdBaseFile::getDosName |
( |
char *const |
name | ) |
|
454 bsod(
"get dos name of a file");
◆ ls()
◆ mkdir()
bool SdBaseFile::mkdir |
( |
SdBaseFile * |
dir, |
|
|
const char * |
path, |
|
|
bool |
pFlag = true |
|
) |
| |
◆ open() [1/3]
◆ open() [2/3]
569 char fullpath[256] = { 0 };
571 strcat(fullpath,
"/");
572 strcat(fullpath, path);
574 auto dirp = &(
_slot_of(dir)->directory);
576 strcat(fullpath,
"/");
577 strcat(fullpath, path);
594 fileSize_ =
f_size(&slot->directory);
615 fileSize_ =
f_size(&slot->file);
◆ open() [3/3]
◆ openNext()
◆ openRoot()
bool SdBaseFile::openRoot |
( |
SdVolume * |
vol | ) |
|
◆ peek()
◆ printFatDate()
static void SdBaseFile::printFatDate |
( |
uint16_t |
fatDate | ) |
|
|
static |
◆ printFatTime()
static void SdBaseFile::printFatTime |
( |
uint16_t |
fatTime | ) |
|
|
static |
◆ printName()
bool SdBaseFile::printName |
( |
| ) |
|
◆ read() [1/2]
int16_t SdBaseFile::read |
( |
void |
| ) |
|
◆ read() [2/2]
int16_t SdBaseFile::read |
( |
void * |
buf, |
|
|
uint16_t |
nbyte |
|
) |
| |
519 DBG(
"NOT IMPLEMENTED: read(...)");
◆ readDir()
int8_t SdBaseFile::readDir |
( |
dir_t * |
dir, |
|
|
char * |
longFilename |
|
) |
| |
465 char *altname = nfo.altname;
466 char *fname = nfo.
fname;
468 char *altname = nfo.
fname;
472 longFilename[0] =
'\0';
477 memset(dir->
name,
' ', 11);
478 str = strchr(altname,
'.');
480 strncpy(((
char *)dir->
name) + 0, altname, str - altname);
481 strncpy(((
char *)dir->
name) + 8, str + 1, 3);
483 strncpy(((
char *)dir->
name) + 0, altname, 8);
494 strncpy(longFilename, fname,
_MAX_LFN);
500 return sizeof(
dir_t);
◆ remove() [1/2]
◆ remove() [2/2]
bool SdBaseFile::remove |
( |
| ) |
|
◆ rewind()
void SdBaseFile::rewind |
( |
| ) |
|
Set the file's current position to zero.
◆ rename()
◆ rmdir()
bool SdBaseFile::rmdir |
( |
| ) |
|
◆ rmRfStar()
bool SdBaseFile::rmRfStar |
( |
| ) |
|
◆ seekCur()
bool SdBaseFile::seekCur |
( |
const int32_t |
offset | ) |
|
Set the files position to current position + pos. See seekSet().
- Parameters
-
[in] | offset | The new position in bytes from the current position. |
- Returns
- true for success or false for failure.
321 {
return seekSet(curPosition_ + offset); }
◆ seekEnd()
bool SdBaseFile::seekEnd |
( |
const int32_t |
offset = 0 | ) |
|
Set the files position to end-of-file + offset. See seekSet().
- Parameters
-
[in] | offset | The new position in bytes from end-of-file. |
- Returns
- true for success or false for failure.
328 {
return seekSet(fileSize_ + offset); }
◆ seekSet()
bool SdBaseFile::seekSet |
( |
const uint32_t |
pos | ) |
|
◆ sync()
bool SdBaseFile::sync |
( |
| ) |
|
◆ timestamp() [1/2]
◆ timestamp() [2/2]
◆ type()
◆ truncate()
bool SdBaseFile::truncate |
( |
uint32_t |
size | ) |
|
◆ volume()
- Returns
- SdVolume that contains this file.
◆ write()
int16_t SdBaseFile::write |
( |
const void * |
buf, |
|
|
uint16_t |
nbyte |
|
) |
| |
◆ SdFat
◆ writeError
bool SdBaseFile::writeError |
writeError is set to true if an error occurs during a write(). Set writeError to false before calling print() and/or write() and check for true after calls to print() and/or write().
bool seekSet(const uint32_t pos)
Definition: Marlin_CardReader.cpp:505
const uint8_t FAT_FILE_TYPE_NORMAL
Definition: SdBaseFile.h:81
const uint8_t FAT_FILE_TYPE_SUBDIR
Definition: SdBaseFile.h:84
const uint8_t FAT_FILE_TYPE_ROOT_FIXED
Definition: SdBaseFile.h:82
uint16_t lastWriteTime
Definition: SdFatStructs.h:522
static void fname_from_8_3(char *fn, char *fn83)
Definition: Marlin_CardReader.cpp:418
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
Definition: ff.c:4412
#define FA_WRITE
Definition: ff.h:327
BYTE fattrib
Definition: ff.h:201
#define pd
Definition: screen_filebrowser.cpp:39
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
FIL file
Definition: Marlin_CardReader.cpp:41
bool close()
Definition: Marlin_CardReader.cpp:535
WORD fdate
Definition: ff.h:199
const uint8_t DIR_NAME_DELETED
Definition: SdFatStructs.h:561
static uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second)
Definition: SdBaseFile.h:129
#define f_rewinddir(dp)
Definition: ff.h:282
FRESULT f_getdirpath(DIR *pd, TCHAR *buff, UINT len)
DIR directory
Definition: Marlin_CardReader.cpp:42
DWORD FSIZE_t
Definition: ff.h:78
#define _slot_of(x)
Definition: Marlin_CardReader.cpp:83
const uint8_t O_WRITE
Definition: SdBaseFile.h:55
bool isOpen() const
Definition: SdBaseFile.h:277
Definition: Marlin_CardReader.cpp:31
#define FA_READ
Definition: ff.h:326
struct directoryEntry dir_t
Definition: SdFatStructs.h:557
#define f_size(fp)
Definition: ff.h:280
WORD ftime
Definition: ff.h:200
uint16_t lastWriteDate
Definition: SdFatStructs.h:523
FRESULT f_opendir(DIR *dp, const TCHAR *path)
Definition: ff.c:4221
uint8_t name[11]
Definition: SdFatStructs.h:486
#define DBG
Definition: Marlin_CardReader.cpp:9
#define _MAX_LFN
Definition: ffconf.h:150
static uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day)
Definition: SdBaseFile.h:95
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
Definition: ff.c:4060
static void free(Slot *slot)
Definition: Marlin_CardReader.cpp:62
uint8_t attributes
Definition: SdFatStructs.h:494
const uint8_t FAT_FILE_TYPE_MIN_DIR
Definition: SdBaseFile.h:85
const uint8_t[]
Definition: 404_html.c:3
TCHAR fname[13]
Definition: ff.h:206
const uint8_t FAT_FILE_TYPE_CLOSED
Definition: SdBaseFile.h:80
FRESULT
Definition: ff.h:214
#define AM_DIR
Definition: ff.h:354
bool writeError
Definition: SdBaseFile.h:177
#define bsod(fmt,...)
Definition: bsod.h:20
Definition: Marlin_CardReader.cpp:34
unsigned char BYTE
Definition: onboard_sd.h:13
uint32_t fileSize
Definition: SdFatStructs.h:525
FRESULT f_closedir(DIR *dp)
Definition: ff.c:4291
bool isRoot() const
Definition: SdBaseFile.h:287
png_structrp int mode
Definition: png.h:1139
const uint8_t O_READ
Definition: SdBaseFile.h:53
list b
Definition: createSpeedLookupTable.py:30
static Slot * allocate(Type type)
Definition: Marlin_CardReader.cpp:51
unsigned int UINT
Definition: onboard_sd.h:16
const uint8_t DIR_NAME_FREE
Definition: SdFatStructs.h:562
FRESULT f_readdir(DIR *dp, FILINFO *fno)
Definition: ff.c:4324
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Definition: ff.c:3499
FRESULT f_close(FIL *fp)
Definition: ff.c:3801
bool isDir() const
Definition: SdBaseFile.h:267
Definition: Marlin_CardReader.cpp:35
FSIZE_t fsize
Definition: ff.h:198
const uint8_t FAT_FILE_TYPE_ROOT32
Definition: SdBaseFile.h:83