From 71f15f99f672455855aeb7ea294382ec61fc8f3a Mon Sep 17 00:00:00 2001 From: Arisotura Date: Mon, 11 Oct 2021 00:48:30 +0200 Subject: [PATCH] give the fatfs types names that won't conflict with stdio shit --- src/DSi_NAND.cpp | 42 ++++++++++----------- src/FATStorage.cpp | 83 ++++++++++------------------------------- src/fatfs/ff.c | 92 +++++++++++++++++++++++----------------------- src/fatfs/ff.h | 50 ++++++++++++------------- 4 files changed, 111 insertions(+), 156 deletions(-) diff --git a/src/DSi_NAND.cpp b/src/DSi_NAND.cpp index 23f4a836..f4f68d45 100644 --- a/src/DSi_NAND.cpp +++ b/src/DSi_NAND.cpp @@ -441,7 +441,7 @@ bool ESDecrypt(u8* data, u32 len) void ReadHardwareInfo(u8* dataS, u8* dataN) { - FIL file; + FF_FIL file; FRESULT res; u32 nread; @@ -463,11 +463,11 @@ void ReadHardwareInfo(u8* dataS, u8* dataN) void ReadUserData(u8* data) { - FIL file; + FF_FIL file; FRESULT res; u32 nread; - FIL f1, f2; + FF_FIL f1, f2; int v1, v2; res = f_open(&f1, "0:/shared1/TWLCFG0.dat", FA_OPEN_EXISTING | FA_READ); @@ -519,7 +519,7 @@ void PatchTSC() char filename[64]; sprintf(filename, "0:/shared1/TWLCFG%d.dat", i); - FIL file; + FF_FIL file; res = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ | FA_WRITE); if (res != FR_OK) { @@ -557,8 +557,8 @@ void PatchTSC() void debug_listfiles(const char* path) { - fDIR dir; - FILINFO info; + FF_DIR dir; + FF_FILINFO info; FRESULT res; res = f_opendir(&dir, path); @@ -585,7 +585,7 @@ void debug_listfiles(const char* path) bool ImportFile(const char* path, const char* in) { - FIL file; + FF_FIL file; FILE* fin; FRESULT res; @@ -626,7 +626,7 @@ bool ImportFile(const char* path, const char* in) bool ExportFile(const char* path, const char* out) { - FIL file; + FF_FIL file; FILE* fout; FRESULT res; @@ -665,7 +665,7 @@ bool ExportFile(const char* path, const char* out) void RemoveFile(const char* path) { - FILINFO info; + FF_FILINFO info; FRESULT res = f_stat(path, &info); if (res != FR_OK) return; @@ -677,8 +677,8 @@ void RemoveFile(const char* path) void RemoveDir(const char* path) { - fDIR dir; - FILINFO info; + FF_DIR dir; + FF_FILINFO info; FRESULT res; res = f_stat(path, &info); @@ -734,7 +734,7 @@ u32 GetTitleVersion(u32 category, u32 titleid) FRESULT res; char path[256]; sprintf(path, "0:/title/%08x/%08x/content/title.tmd", category, titleid); - FIL file; + FF_FIL file; res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ); if (res != FR_OK) return 0xFFFFFFFF; @@ -752,7 +752,7 @@ u32 GetTitleVersion(u32 category, u32 titleid) void ListTitles(u32 category, std::vector& titlelist) { FRESULT res; - fDIR titledir; + FF_DIR titledir; char path[256]; sprintf(path, "0:/title/%08x", category); @@ -765,7 +765,7 @@ void ListTitles(u32 category, std::vector& titlelist) for (;;) { - FILINFO info; + FF_FILINFO info; f_readdir(&titledir, &info); if (!info.fname[0]) break; @@ -782,7 +782,7 @@ void ListTitles(u32 category, std::vector& titlelist) continue; sprintf(path, "0:/title/%08x/%08x/content/%08x.app", category, titleid, version); - FILINFO appinfo; + FF_FILINFO appinfo; res = f_stat(path, &appinfo); if (res != FR_OK) continue; @@ -817,7 +817,7 @@ void GetTitleInfo(u32 category, u32 titleid, u32& version, NDSHeader* header, ND char path[256]; sprintf(path, "0:/title/%08x/%08x/content/%08x.app", category, titleid, version); - FIL file; + FF_FIL file; res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ); if (res != FR_OK) return; @@ -845,7 +845,7 @@ void GetTitleInfo(u32 category, u32 titleid, u32& version, NDSHeader* header, ND bool CreateTicket(const char* path, u32 titleid0, u32 titleid1, u8 version) { - FIL file; + FF_FIL file; FRESULT res; u32 nwrite; @@ -911,7 +911,7 @@ bool CreateSaveFile(const char* path, u32 len) if (len == 0x4000) totsec16 = 27; else totsec16 = len >> 9; - FIL file; + FF_FIL file; FRESULT res; u32 nwrite; @@ -969,11 +969,11 @@ bool ImportTitle(const char* appfile, u8* tmd, bool readonly) printf("Title ID: %08x/%08x\n", titleid0, titleid1); FRESULT res; - fDIR ticketdir; - FILINFO info; + FF_DIR ticketdir; + FF_FILINFO info; char fname[128]; - FIL file; + FF_FIL file; u32 nwrite; // ticket diff --git a/src/FATStorage.cpp b/src/FATStorage.cpp index 173dfe16..c29cdb56 100644 --- a/src/FATStorage.cpp +++ b/src/FATStorage.cpp @@ -264,7 +264,7 @@ void FATStorage::SaveIndex() bool FATStorage::ExportFile(std::string path, std::string out, fs::file_time_type& modtime) { - FIL file; + FF_FIL file; FILE* fout; FRESULT res; @@ -316,8 +316,8 @@ void FATStorage::ExportDirectory(std::string path, std::string outbase, int leve { if (level >= 32) return; - fDIR dir; - FILINFO info; + FF_DIR dir; + FF_FILINFO info; FRESULT res; printf("EXPORTING DIRECTORY %s (base %s level %d)\n", path.c_str(), outbase.c_str(), level); std::string fullpath = "0:/" + path; @@ -494,7 +494,7 @@ void FATStorage::ExportChanges(std::string outbase) for (const auto& [key, val] : FileIndex) { std::string innerpath = "0:/" + val.Path; - FILINFO finfo; + FF_FILINFO finfo; FRESULT res = f_stat(innerpath.c_str(), &finfo); if (res == FR_OK) { @@ -528,7 +528,7 @@ void FATStorage::ExportChanges(std::string outbase) for (const auto& [key, val] : DirIndex) { std::string innerpath = "0:/" + val.Path; - FILINFO finfo; + FF_FILINFO finfo; FRESULT res = f_stat(innerpath.c_str(), &finfo); if (res == FR_OK) { @@ -574,8 +574,8 @@ bool FATStorage::DeleteDirectory(std::string path, int level) if (level >= 32) return false; if (path.length() < 1) return false; - fDIR dir; - FILINFO info; + FF_DIR dir; + FF_FILINFO info; FRESULT res; std::string fullpath = "0:/" + path; @@ -635,8 +635,8 @@ void FATStorage::CleanupDirectory(std::string sourcedir, std::string path, int l { if (level >= 32) return; - fDIR dir; - FILINFO info; + FF_DIR dir; + FF_FILINFO info; FRESULT res; printf("CLEANING UP DIRECTORY %s (level=%d)\n", path.c_str(), level); std::string fullpath = "0:/" + path; @@ -703,7 +703,7 @@ printf("FOUND ENTRY %s %08X (%d/%d, %d)\n", bool FATStorage::ImportFile(std::string path, std::string in) { - FIL file; + FF_FIL file; FILE* fin; FRESULT res; @@ -833,7 +833,7 @@ bool FATStorage::BuildSubdirectory(const char* sourcedir, const char* path, int innerpath = "0:/" + innerpath; if (ImportFile(innerpath, fullpath)) { - FILINFO finfo; + FF_FILINFO finfo; f_stat(innerpath.c_str(), &finfo); ientry.LastModifiedInternal = (finfo.fdate << 16) | finfo.ftime; @@ -853,59 +853,8 @@ bool FATStorage::BuildSubdirectory(const char* sourcedir, const char* path, int return false; } - char fullpath[1024] = {0}; - snprintf(fullpath, 1023, "%s%s", sourcedir, path); - DIR* dir = opendir(fullpath); - if (!dir) return false; - - bool res = true; - for (;;) - { - errno = 0; - struct dirent* entry = readdir(dir); - if (!entry) - { - if (errno != 0) res = false; - break; - } - - if (entry->d_name[0] == '.') - { - if (entry->d_name[1] == '\0') continue; - if (entry->d_name[1] == '.' && entry->d_name[2] == '\0') continue; - } - - snprintf(fullpath, 1023, "%s%s/%s", sourcedir, path, entry->d_name); - - int entrytype = GetDirEntryType(fullpath, entry); - if (entrytype == -1) continue; - - if (entrytype == 1) // directory - { - snprintf(fullpath, 1023, "0:%s/%s", path, entry->d_name); - FRESULT fres = f_mkdir(fullpath); - if (fres == FR_OK) - { - if (!BuildSubdirectory(sourcedir, &fullpath[2], level+1)) - res = false; - } - else - res = false; - } - else // file - { - char importpath[1024] = {0}; - snprintf(importpath, 1023, "0:%s/%s", path, entry->d_name); - printf("importing %s to %s\n", fullpath, importpath); - if (!ImportFile(importpath, fullpath)) - res = false; - } - } - - closedir(dir); - - return res; + return false; } bool FATStorage::Build(const char* sourcedir, u64 size, const char* filename) @@ -936,7 +885,13 @@ bool FATStorage::Build(const char* sourcedir, u64 size, const char* filename) // TODO: determine proper FAT type! // for example: libfat tries to determine the FAT type from the number of clusters // which doesn't match the way fatfs handles autodetection - MKFS_PARM fsopt; + // + // partition->dataStart = partition->rootDirStart + (( u8array_to_u16(sectorBuffer, BPB_rootEntries) * DIR_ENTRY_DATA_SIZE) / partition->bytesPerSector); + // uint32_t clusterCount = (partition->numberOfSectors - (uint32_t)(partition->dataStart - startSector)) / partition->sectorsPerCluster; + // FAT12: max cluster count 4085 + // FAT16; max cluster count: 65525 + // + FF_MKFS_PARM fsopt; fsopt.fmt = FM_FAT;// | FM_FAT32; fsopt.au_size = 0; fsopt.align = 1; diff --git a/src/fatfs/ff.c b/src/fatfs/ff.c index a4fbaa8f..9d212949 100644 --- a/src/fatfs/ff.c +++ b/src/fatfs/ff.c @@ -1595,7 +1595,7 @@ static DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:D /*-----------------------------------------------------------------------*/ static DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ + FF_FIL* fp, /* Pointer to the file object */ FSIZE_t ofs /* File offset to be converted to cluster# */ ) { @@ -1664,7 +1664,7 @@ static FRESULT dir_clear ( /* Returns FR_OK or FR_DISK_ERR */ /*-----------------------------------------------------------------------*/ static FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */ - fDIR* dp, /* Pointer to directory object */ + FF_DIR* dp, /* Pointer to directory object */ DWORD ofs /* Offset of directory table */ ) { @@ -1712,7 +1712,7 @@ static FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */ /*-----------------------------------------------------------------------*/ static FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - fDIR* dp, /* Pointer to the directory object */ + FF_DIR* dp, /* Pointer to the directory object */ int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ ) { @@ -1773,7 +1773,7 @@ static FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DEN /*-----------------------------------------------------------------------*/ static FRESULT dir_alloc ( /* FR_OK(0):succeeded, !=0:error */ - fDIR* dp, /* Pointer to the directory object */ + FF_DIR* dp, /* Pointer to the directory object */ UINT n_ent /* Number of contiguous entries to allocate */ ) { @@ -2273,7 +2273,7 @@ static void create_xdir ( #define DIR_READ_LABEL(dp) dir_read(dp, 1) static FRESULT dir_read ( - fDIR* dp, /* Pointer to the directory object */ + FF_DIR* dp, /* Pointer to the directory object */ int vol /* Filtered by 0:file/directory or 1:volume label */ ) { @@ -2351,7 +2351,7 @@ static FRESULT dir_read ( /*-----------------------------------------------------------------------*/ static FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */ - fDIR* dp /* Pointer to the directory object with the file name */ + FF_DIR* dp /* Pointer to the directory object with the file name */ ) { FRESULT res; @@ -2432,7 +2432,7 @@ static FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */ /*-----------------------------------------------------------------------*/ static FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */ - fDIR* dp /* Target directory with object name to be created */ + FF_DIR* dp /* Target directory with object name to be created */ ) { FRESULT res; @@ -2538,7 +2538,7 @@ static FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too /*-----------------------------------------------------------------------*/ static FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ - fDIR* dp /* Directory object pointing the entry to be removed */ + FF_DIR* dp /* Directory object pointing the entry to be removed */ ) { FRESULT res; @@ -2584,8 +2584,8 @@ static FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ /*-----------------------------------------------------------------------*/ static void get_fileinfo ( - fDIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ + FF_DIR* dp, /* Pointer to the directory object */ + FF_FILINFO* fno /* Pointer to the file information to be filled */ ) { UINT si, di; @@ -2799,7 +2799,7 @@ static int pattern_match ( /* 0:mismatched, 1:matched */ /*-----------------------------------------------------------------------*/ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */ - fDIR* dp, /* Pointer to the directory object */ + FF_DIR* dp, /* Pointer to the directory object */ const TCHAR** path /* Pointer to pointer to the segment in the path string */ ) { @@ -3001,7 +3001,7 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not cr /*-----------------------------------------------------------------------*/ static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - fDIR* dp, /* Directory object to return last directory and found object */ + FF_DIR* dp, /* Directory object to return last directory and found object */ const TCHAR* path /* Full-path string to find a file or directory */ ) { @@ -3651,13 +3651,13 @@ FRESULT f_mount ( /*-----------------------------------------------------------------------*/ FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ + FF_FIL* fp, /* Pointer to the blank file object */ const TCHAR* path, /* Pointer to the file name */ BYTE mode /* Access mode and open mode flags */ ) { FRESULT res; - fDIR dj; + FF_DIR dj; FATFS *fs; #if !FF_FS_READONLY DWORD cl, bcs, clst, tm; @@ -3848,7 +3848,7 @@ FRESULT f_open ( /*-----------------------------------------------------------------------*/ FRESULT f_read ( - FIL* fp, /* Open file to be read */ + FF_FIL* fp, /* Open file to be read */ void* buff, /* Data buffer to store the read data */ UINT btr, /* Number of bytes to read */ UINT* br /* Number of bytes read */ @@ -3948,7 +3948,7 @@ FRESULT f_read ( /*-----------------------------------------------------------------------*/ FRESULT f_write ( - FIL* fp, /* Open file to be written */ + FF_FIL* fp, /* Open file to be written */ const void* buff, /* Data to be written */ UINT btw, /* Number of bytes to write */ UINT* bw /* Number of bytes written */ @@ -4069,7 +4069,7 @@ FRESULT f_write ( /*-----------------------------------------------------------------------*/ FRESULT f_sync ( - FIL* fp /* Open file to be synced */ + FF_FIL* fp /* Open file to be synced */ ) { FRESULT res; @@ -4150,7 +4150,7 @@ FRESULT f_sync ( /*-----------------------------------------------------------------------*/ FRESULT f_close ( - FIL* fp /* Open file to be closed */ + FF_FIL* fp /* Open file to be closed */ ) { FRESULT res; @@ -4365,7 +4365,7 @@ FRESULT f_getcwd ( /*-----------------------------------------------------------------------*/ FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ + FF_FIL* fp, /* Pointer to the file object */ FSIZE_t ofs /* File pointer from top of file */ ) { @@ -4529,7 +4529,7 @@ FRESULT f_lseek ( /*-----------------------------------------------------------------------*/ FRESULT f_opendir ( - fDIR* dp, /* Pointer to directory object to create */ + FF_DIR* dp, /* Pointer to directory object to create */ const TCHAR* path /* Pointer to the directory path */ ) { @@ -4595,7 +4595,7 @@ FRESULT f_opendir ( /*-----------------------------------------------------------------------*/ FRESULT f_closedir ( - fDIR *dp /* Pointer to the directory object to be closed */ + FF_DIR *dp /* Pointer to the directory object to be closed */ ) { FRESULT res; @@ -4625,8 +4625,8 @@ FRESULT f_closedir ( /*-----------------------------------------------------------------------*/ FRESULT f_readdir ( - fDIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ + FF_DIR* dp, /* Pointer to the open directory object */ + FF_FILINFO* fno /* Pointer to file information to return */ ) { FRESULT res; @@ -4661,8 +4661,8 @@ FRESULT f_readdir ( /*-----------------------------------------------------------------------*/ FRESULT f_findnext ( - fDIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to the file information structure */ + FF_DIR* dp, /* Pointer to the open directory object */ + FF_FILINFO* fno /* Pointer to the file information structure */ ) { FRESULT res; @@ -4686,8 +4686,8 @@ FRESULT f_findnext ( /*-----------------------------------------------------------------------*/ FRESULT f_findfirst ( - fDIR* dp, /* Pointer to the blank directory object */ - FILINFO* fno, /* Pointer to the file information structure */ + FF_DIR* dp, /* Pointer to the blank directory object */ + FF_FILINFO* fno, /* Pointer to the file information structure */ const TCHAR* path, /* Pointer to the directory to open */ const TCHAR* pattern /* Pointer to the matching pattern */ ) @@ -4714,11 +4714,11 @@ FRESULT f_findfirst ( FRESULT f_stat ( const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ + FF_FILINFO* fno /* Pointer to file information to return */ ) { FRESULT res; - fDIR dj; + FF_DIR dj; DEF_NAMBUF @@ -4840,7 +4840,7 @@ FRESULT f_getfree ( /*-----------------------------------------------------------------------*/ FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ + FF_FIL* fp /* Pointer to the file object */ ) { FRESULT res; @@ -4894,7 +4894,7 @@ FRESULT f_unlink ( ) { FRESULT res; - fDIR dj, sdj; + FF_DIR dj, sdj; DWORD dclst = 0; FATFS *fs; #if FF_FS_EXFAT @@ -4988,7 +4988,7 @@ FRESULT f_mkdir ( ) { FRESULT res; - fDIR dj; + FF_DIR dj; FFOBJID sobj; FATFS *fs; DWORD dcl, pcl, tm; @@ -5073,7 +5073,7 @@ FRESULT f_rename ( ) { FRESULT res; - fDIR djo, djn; + FF_DIR djo, djn; FATFS *fs; BYTE buf[FF_FS_EXFAT ? SZDIRE * 2 : SZDIRE], *dir; LBA_t sect; @@ -5121,7 +5121,7 @@ FRESULT f_rename ( #endif { /* At FAT/FAT32 volume */ memcpy(buf, djo.dir, SZDIRE); /* Save directory entry of the object */ - memcpy(&djn, &djo, sizeof (fDIR)); /* Duplicate the directory object */ + memcpy(&djn, &djo, sizeof (FF_DIR)); /* Duplicate the directory object */ res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */ if (res == FR_OK) { /* Is new name already in use by any other object? */ res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST; @@ -5184,7 +5184,7 @@ FRESULT f_chmod ( ) { FRESULT res; - fDIR dj; + FF_DIR dj; FATFS *fs; DEF_NAMBUF @@ -5226,11 +5226,11 @@ FRESULT f_chmod ( FRESULT f_utime ( const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the timestamp to be set */ + const FF_FILINFO* fno /* Pointer to the timestamp to be set */ ) { FRESULT res; - fDIR dj; + FF_DIR dj; FATFS *fs; DEF_NAMBUF @@ -5489,7 +5489,7 @@ FRESULT f_setlabel ( /*-----------------------------------------------------------------------*/ FRESULT f_expand ( - FIL* fp, /* Pointer to the file object */ + FF_FIL* fp, /* Pointer to the file object */ FSIZE_t fsz, /* File size to be expanded to */ BYTE opt /* Operation mode 0:Find and prepare or 1:Find and allocate */ ) @@ -5579,7 +5579,7 @@ FRESULT f_expand ( /*-----------------------------------------------------------------------*/ FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ + FF_FIL* fp, /* Pointer to the file object */ UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ UINT btf, /* Number of bytes to forward */ UINT* bf /* Pointer to number of bytes forwarded */ @@ -5801,14 +5801,14 @@ static FRESULT create_partition ( FRESULT f_mkfs ( const TCHAR* path, /* Logical drive number */ - const MKFS_PARM* opt, /* Format options */ + const FF_MKFS_PARM* opt, /* Format options */ void* work, /* Pointer to working buffer (null: use heap memory) */ UINT len /* Size of working buffer [byte] */ ) { static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */ static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ - static const MKFS_PARM defopt = {FM_ANY, 0, 0, 0, 0}; /* Default parameter */ + static const FF_MKFS_PARM defopt = {FM_ANY, 0, 0, 0, 0}; /* Default parameter */ BYTE fsopt, fsty, sys, *buf, *pte, pdrv, ipart; WORD ss; /* Sector size */ DWORD sz_buf, sz_blk, n_clst, pau, nsect, n, vsn; @@ -6338,7 +6338,7 @@ FRESULT f_fdisk ( TCHAR* f_gets ( TCHAR* buff, /* Pointer to the buffer to store read string */ int len, /* Size of string buffer (items) */ - FIL* fp /* Pointer to the file object */ + FF_FIL* fp /* Pointer to the file object */ ) { int nc = 0; @@ -6629,7 +6629,7 @@ static int putc_flush (putbuff* pb) /* Initialize write buffer */ -static void putc_init (putbuff* pb, FIL* fp) +static void putc_init (putbuff* pb, FF_FIL* fp) { memset(pb, 0, sizeof (putbuff)); pb->fp = fp; @@ -6639,7 +6639,7 @@ static void putc_init (putbuff* pb, FIL* fp) int f_putc ( TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ + FF_FIL* fp /* Pointer to the file object */ ) { putbuff pb; @@ -6659,7 +6659,7 @@ int f_putc ( int f_puts ( const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ + FF_FIL* fp /* Pointer to the file object */ ) { putbuff pb; @@ -6799,7 +6799,7 @@ static void ftoa ( int f_printf ( - FIL* fp, /* Pointer to the file object */ + FF_FIL* fp, /* Pointer to the file object */ const TCHAR* fmt, /* Pointer to the format string */ ... /* Optional arguments... */ ) diff --git a/src/fatfs/ff.h b/src/fatfs/ff.h index 779ec70e..800e47bb 100644 --- a/src/fatfs/ff.h +++ b/src/fatfs/ff.h @@ -219,7 +219,7 @@ typedef struct { #if !FF_FS_TINY BYTE buf[FF_MAX_SS]; /* File private data read/write window */ #endif -} FIL; +} FF_FIL; @@ -238,7 +238,7 @@ typedef struct { #if FF_USE_FIND const TCHAR* pat; /* Pointer to the name matching pattern */ #endif -} fDIR; +} FF_DIR; @@ -255,7 +255,7 @@ typedef struct { #else TCHAR fname[12 + 1]; /* File name */ #endif -} FILINFO; +} FF_FILINFO; @@ -267,7 +267,7 @@ typedef struct { UINT align; /* Data area alignment (sector) */ UINT n_root; /* Number of root directory entries */ DWORD au_size; /* Cluster size (byte) */ -} MKFS_PARM; +} FF_MKFS_PARM; @@ -301,40 +301,40 @@ typedef enum { /*--------------------------------------------------------------*/ /* FatFs module application interface */ -FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ -FRESULT f_close (FIL* fp); /* Close an open file object */ -FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ -FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ -FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ -FRESULT f_truncate (FIL* fp); /* Truncate the file */ -FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ -FRESULT f_opendir (fDIR* dp, const TCHAR* path); /* Open a directory */ -FRESULT f_closedir (fDIR* dp); /* Close an open directory */ -FRESULT f_readdir (fDIR* dp, FILINFO* fno); /* Read a directory item */ -FRESULT f_findfirst (fDIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ -FRESULT f_findnext (fDIR* dp, FILINFO* fno); /* Find next file */ +FRESULT f_open (FF_FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ +FRESULT f_close (FF_FIL* fp); /* Close an open file object */ +FRESULT f_read (FF_FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ +FRESULT f_write (FF_FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ +FRESULT f_lseek (FF_FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ +FRESULT f_truncate (FF_FIL* fp); /* Truncate the file */ +FRESULT f_sync (FF_FIL* fp); /* Flush cached data of the writing file */ +FRESULT f_opendir (FF_DIR* dp, const TCHAR* path); /* Open a directory */ +FRESULT f_closedir (FF_DIR* dp); /* Close an open directory */ +FRESULT f_readdir (FF_DIR* dp, FF_FILINFO* fno); /* Read a directory item */ +FRESULT f_findfirst (FF_DIR* dp, FF_FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ +FRESULT f_findnext (FF_DIR* dp, FF_FILINFO* fno); /* Find next file */ FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ -FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ +FRESULT f_stat (const TCHAR* path, FF_FILINFO* fno); /* Get file status */ FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */ -FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */ +FRESULT f_utime (const TCHAR* path, const FF_FILINFO* fno); /* Change timestamp of a file/dir */ FRESULT f_chdir (const TCHAR* path); /* Change current directory */ FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ -FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */ +FRESULT f_forward (FF_FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ +FRESULT f_expand (FF_FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */ FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ -FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */ +FRESULT f_mkfs (const TCHAR* path, const FF_MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */ FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */ FRESULT f_setcp (WORD cp); /* Set current code page */ -int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ -int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ -int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ -TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ +int f_putc (TCHAR c, FF_FIL* fp); /* Put a character to the file */ +int f_puts (const TCHAR* str, FF_FIL* cp); /* Put a string to the file */ +int f_printf (FF_FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ +TCHAR* f_gets (TCHAR* buff, int len, FF_FIL* fp); /* Get a string from the file */ #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) #define f_error(fp) ((fp)->err)