52#if defined (FT900_PLATFORM) || defined (FT93X_PLATFORM) || defined (RP2040_PLATFORM)
59#if defined (FT900_PLATFORM) || defined (FT93X_PLATFORM) || defined (RP2040_PLATFORM)
67static FRESULT scan_files(
char* path ) {
81 sprintf(&path[i],
"/%s", fno.
fname);
82 res = scan_files(path);
87 printf(
"%s/%s\n", path, fno.
fname);
92 printf(
"Error on open %s, res = %d", path, res);
106 memset(&
fp, 0,
sizeof(
FIL));
110 printf(
"Closed file\n");
123 printf(
"File haven't openned\n");
128 if (fResult !=
FR_OK) {
129 printf(
"Seek error, error: %d\n", fResult);
142 printf(
"File haven't openned\n");
170 printf(
"File open mode is not recognized\n");
173 fResult =
f_open(&
fp, filePath, mode);
174 if (fResult !=
FR_OK) {
175 printf(
"Cannot open %s, please check SD card, error: %d\n", filePath,
190 printf(
"Opened file %s, file size: %d bytes\n", filePath,
filesz);
203 unsigned int bytesread = 0;
204 unsigned int bytescount = 0;
205 unsigned int bytescounts = 0;
206 int chunk_size = 1024;
210 printf(
"File haven't opened\n");
214 printf(
"Reached EOF\n");
218 while (bytescounts < bytes) {
219 chunk_size = bytes > chunk_size ? chunk_size : bytes;
222 fResult =
f_read(&
fp, &
buffer[bytescounts], bytesread, &bytescount);
223 if (fResult !=
FR_OK) {
224 printf(
"Error on f_read\n");
227 bytescounts += bytescount;
229 if (bytesread != bytescount) {
230 printf(
"Reached EOF, stop\n");
236 printf(
"Reached EOF\n");
255 unsigned int written = 0;
258 printf(
"File haven't openned\n");
264 if (fResult !=
FR_OK) {
265 printf(
"Error on f_write\n");
268 if (buffersize != written) {
269 printf(
"Writting error\n");
299 printf(
"Reached Eof\n");
304#elif defined (MSVC_PLATFORM) || defined (BT8XXEMU_PLATFORM)
331 printf(
"Seeking to %ld\n", offset);
334 printf(
"File haven't openned\n");
338 ret = fseek(
fp, offset, SEEK_SET);
341 printf(
"Seek to %lu error, error: %d\n", offset, ret);
354 printf(
"File haven't openned\n");
386 printf(
"File open mode is not recognized\n");
391#pragma warning(disable : 4996)
392 fp = fopen(filePath, mode);
395 printf(
"Cannot open %s, please check SD card, error: %d\n", filePath, errno);
399 fseek(
fp, 0, SEEK_END);
401 fseek(
fp, 0, SEEK_SET);
404 printf(
"Opened %s, file size: %ld\n", filePath,
filesz);
422 const int chunkSize = 1024;
428 printf(
"File is not opening\n");
433 printf(
"Reached EOF\n");
438 blockSize = chunkSize > size ? size : chunkSize;
440 byteRead = (int)fread(&
buffer[offset], 1, blockSize,
fp);
445 if (!feof(
fp) && blockSize != byteRead) {
446 printf(
"Error on f_read\n");
469 printf(
"File haven't openned\n");
473 written = (int)fwrite(
buffer, 1, buffersize,
fp);
475 if (written != buffersize) {
476 printf(
"Writting error: written=%u, Expected=%ld, errno=%d\n", written, buffersize, errno);
499 printf(
"Reached Eof\n");
530 numRead = fileSize - offset;
532 if (offset >= fileSize) {
540 if (size > 0 && size < numRead) {
552 *byteCount = numRead;
568 printf(
"Error open file\n");
static ft_uint32_t ft_uint8_t * buffer
void FileIO_Buffer_To_File(const char *txt, const char *buffer, unsigned long buffersize)
Write a buffer to file.
int FileIO_File_Read(char *buffer, long bytes)
int FileIO_File_List(char *path)
int FileIO_File_Seek(unsigned long offset)
int FileIO_File_Write(const char *buffer, long buffersize)
int FileIO_File_Open(const char *filePath, enum _FILEIO_E_FOPEN e)
char * FileIO_Read_Line()
int FileIO_File_To_Buffer(const char *file, char *buff, long offset, int size, int *byteCount)
Read a whole file to a buffer.
File read-write library for Eve application, support a unique interface for every platform.
TCHAR * f_gets(TCHAR *buff, int len, FIL *fp)
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
FRESULT f_readdir(DIR *dp, FILINFO *fno)
FRESULT f_closedir(DIR *dp)
FRESULT f_opendir(DIR *dp, const TCHAR *path)
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
TCHAR fname[FF_LFN_BUF+1]