Externals/FatFs: Avoid conflicts with Windows.h.

This commit is contained in:
Admiral H. Curtiss 2022-04-17 02:39:06 +02:00
parent bd02356e49
commit f43ffca488
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 131 additions and 131 deletions

186
Externals/FatFs/ff.c vendored
View File

@ -728,13 +728,13 @@ static int dbc_2nd (BYTE c)
#if FF_USE_LFN
/* Get a Unicode code point from the TCHAR string in defined API encodeing */
/* Get a Unicode code point from the FATFS_TCHAR string in defined API encodeing */
static DWORD tchar2uni ( /* Returns a character in UTF-16 encoding (>=0x10000 on surrogate pair, 0xFFFFFFFF on decode error) */
const TCHAR** str /* Pointer to pointer to TCHAR string in configured encoding */
const FATFS_TCHAR** str /* Pointer to pointer to FATFS_TCHAR string in configured encoding */
)
{
DWORD uc;
const TCHAR *p = *str;
const FATFS_TCHAR *p = *str;
#if FF_LFN_UNICODE == 1 /* UTF-16 input */
WCHAR wc;
@ -771,7 +771,7 @@ static DWORD tchar2uni ( /* Returns a character in UTF-16 encoding (>=0x10000 on
}
#elif FF_LFN_UNICODE == 3 /* UTF-32 input */
uc = (TCHAR)*p++; /* Get a unit */
uc = (FATFS_TCHAR)*p++; /* Get a unit */
if (uc >= 0x110000 || IsSurrogate(uc)) return 0xFFFFFFFF; /* Wrong code? */
if (uc >= 0x010000) uc = 0xD800DC00 | ((uc - 0x10000) << 6 & 0x3FF0000) | (uc & 0x3FF); /* Make a surrogate pair if needed */
@ -800,7 +800,7 @@ static DWORD tchar2uni ( /* Returns a character in UTF-16 encoding (>=0x10000 on
/* Store a Unicode char in defined API encoding */
static UINT put_utf ( /* Returns number of encoding units written (0:buffer overflow or wrong encoding) */
DWORD chr, /* UTF-16 encoded character (Surrogate pair if >=0x10000) */
TCHAR* buf, /* Output buffer */
FATFS_TCHAR* buf, /* Output buffer */
UINT szb /* Size of the buffer */
)
{
@ -824,20 +824,20 @@ static UINT put_utf ( /* Returns number of encoding units written (0:buffer over
if (chr < 0x80) { /* Single byte code? */
if (szb < 1) return 0; /* Buffer overflow? */
*buf = (TCHAR)chr;
*buf = (FATFS_TCHAR)chr;
return 1;
}
if (chr < 0x800) { /* 2-byte sequence? */
if (szb < 2) return 0; /* Buffer overflow? */
*buf++ = (TCHAR)(0xC0 | (chr >> 6 & 0x1F));
*buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
*buf++ = (FATFS_TCHAR)(0xC0 | (chr >> 6 & 0x1F));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 0 & 0x3F));
return 2;
}
if (chr < 0x10000) { /* 3-byte sequence? */
if (szb < 3 || IsSurrogate(chr)) return 0; /* Buffer overflow or wrong code? */
*buf++ = (TCHAR)(0xE0 | (chr >> 12 & 0x0F));
*buf++ = (TCHAR)(0x80 | (chr >> 6 & 0x3F));
*buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
*buf++ = (FATFS_TCHAR)(0xE0 | (chr >> 12 & 0x0F));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 6 & 0x3F));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 0 & 0x3F));
return 3;
}
/* 4-byte sequence */
@ -846,10 +846,10 @@ static UINT put_utf ( /* Returns number of encoding units written (0:buffer over
chr = (chr & 0xFFFF) - 0xDC00; /* Get low 10 bits */
if (hc >= 0x100000 || chr >= 0x400) return 0; /* Wrong surrogate? */
chr = (hc | chr) + 0x10000;
*buf++ = (TCHAR)(0xF0 | (chr >> 18 & 0x07));
*buf++ = (TCHAR)(0x80 | (chr >> 12 & 0x3F));
*buf++ = (TCHAR)(0x80 | (chr >> 6 & 0x3F));
*buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
*buf++ = (FATFS_TCHAR)(0xF0 | (chr >> 18 & 0x07));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 12 & 0x3F));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 6 & 0x3F));
*buf++ = (FATFS_TCHAR)(0x80 | (chr >> 0 & 0x3F));
return 4;
#elif FF_LFN_UNICODE == 3 /* UTF-32 output */
@ -862,7 +862,7 @@ static UINT put_utf ( /* Returns number of encoding units written (0:buffer over
if (hc >= 0x100000 || chr >= 0x400) return 0; /* Wrong surrogate? */
chr = (hc | chr) + 0x10000;
}
*buf++ = (TCHAR)chr;
*buf++ = (FATFS_TCHAR)chr;
return 1;
#else /* ANSI/OEM output */
@ -872,11 +872,11 @@ static UINT put_utf ( /* Returns number of encoding units written (0:buffer over
if (wc >= 0x100) { /* Is this a DBC? */
if (szb < 2) return 0;
*buf++ = (char)(wc >> 8); /* Store DBC 1st byte */
*buf++ = (TCHAR)wc; /* Store DBC 2nd byte */
*buf++ = (FATFS_TCHAR)wc; /* Store DBC 2nd byte */
return 2;
}
if (wc == 0 || szb < 1) return 0; /* Invalid char or buffer overflow? */
*buf++ = (TCHAR)wc; /* Store the character */
*buf++ = (FATFS_TCHAR)wc; /* Store the character */
return 1;
#endif
}
@ -2595,7 +2595,7 @@ static void get_fileinfo (
FATFS *fs = dp->obj.fs;
UINT nw;
#else
TCHAR c;
FATFS_TCHAR c;
#endif
@ -2668,7 +2668,7 @@ static void get_fileinfo (
if (nw == 0) { di = 0; break; } /* Buffer overflow? */
di += nw;
#else /* ANSI/OEM output */
fno->altname[di++] = (TCHAR)wc; /* Store it without any conversion */
fno->altname[di++] = (FATFS_TCHAR)wc; /* Store it without any conversion */
#endif
}
fno->altname[di] = 0; /* Terminate the SFN (null string means SFN is invalid) */
@ -2681,7 +2681,7 @@ static void get_fileinfo (
wc = (WCHAR)fno->altname[si];
if (wc == '.') lcf = NS_EXT;
if (IsUpper(wc) && (dp->dir[DIR_NTres] & lcf)) wc += 0x20;
fno->fname[di] = (TCHAR)wc;
fno->fname[di] = (FATFS_TCHAR)wc;
}
}
fno->fname[di] = 0; /* Terminate the LFN */
@ -2691,7 +2691,7 @@ static void get_fileinfo (
#else /* Non-LFN configuration */
si = di = 0;
while (si < 11) { /* Copy name body and extension */
c = (TCHAR)dp->dir[si++];
c = (FATFS_TCHAR)dp->dir[si++];
if (c == ' ') continue; /* Skip padding spaces */
if (c == RDDEM) c = DDEM; /* Restore replaced DDEM character */
if (si == 9) fno->fname[di++] = '.';/* Insert a . if extension is exist */
@ -2719,7 +2719,7 @@ static void get_fileinfo (
static DWORD get_achar ( /* Get a character and advance ptr */
const TCHAR** ptr /* Pointer to pointer to the ANSI/OEM or Unicode string */
const FATFS_TCHAR** ptr /* Pointer to pointer to the ANSI/OEM or Unicode string */
)
{
DWORD chr;
@ -2750,13 +2750,13 @@ static DWORD get_achar ( /* Get a character and advance ptr */
static int pattern_match ( /* 0:mismatched, 1:matched */
const TCHAR* pat, /* Matching pattern */
const TCHAR* nam, /* String to be tested */
const FATFS_TCHAR* pat, /* Matching pattern */
const FATFS_TCHAR* nam, /* String to be tested */
UINT skip, /* Number of pre-skip chars (number of ?s, b8:infinite (* specified)) */
UINT recur /* Recursion count */
)
{
const TCHAR *pptr, *nptr;
const FATFS_TCHAR *pptr, *nptr;
DWORD pchr, nchr;
UINT sk;
@ -2800,7 +2800,7 @@ static int pattern_match ( /* 0:mismatched, 1:matched */
static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */
DIR* dp, /* Pointer to the directory object */
const TCHAR** path /* Pointer to pointer to the segment in the path string */
const FATFS_TCHAR** path /* Pointer to pointer to the segment in the path string */
)
{
#if FF_USE_LFN /* LFN configuration */
@ -2808,7 +2808,7 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not cr
WCHAR wc, *lfn;
DWORD uc;
UINT i, ni, si, di;
const TCHAR *p;
const FATFS_TCHAR *p;
/* Create LFN into LFN working buffer */
@ -3002,7 +3002,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 */
DIR* dp, /* Directory object to return last directory and found object */
const TCHAR* path /* Full-path string to find a file or directory */
const FATFS_TCHAR* path /* Full-path string to find a file or directory */
)
{
FRESULT res;
@ -3088,11 +3088,11 @@ static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */
/*-----------------------------------------------------------------------*/
static int get_ldnumber ( /* Returns logical drive number (-1:invalid drive number or null pointer) */
const TCHAR** path /* Pointer to pointer to the path name */
const FATFS_TCHAR** path /* Pointer to pointer to the path name */
)
{
const TCHAR *tp, *tt;
TCHAR tc;
const FATFS_TCHAR *tp, *tt;
FATFS_TCHAR tc;
int i;
int vol = -1;
#if FF_STR_VOLUME_ID /* Find string volume ID */
@ -3118,7 +3118,7 @@ static int get_ldnumber ( /* Returns logical drive number (-1:invalid drive numb
c = *sp++; tc = *tp++;
if (IsLower(c)) c -= 0x20;
if (IsLower(tc)) tc -= 0x20;
} while (c && (TCHAR)c == tc);
} while (c && (FATFS_TCHAR)c == tc);
} while ((c || tp != tt) && ++i < FF_VOLUMES); /* Repeat for each id until pattern match */
}
#endif
@ -3138,7 +3138,7 @@ static int get_ldnumber ( /* Returns logical drive number (-1:invalid drive numb
c = *sp++; tc = *(++tt);
if (IsLower(c)) c -= 0x20;
if (IsLower(tc)) tc -= 0x20;
} while (c && (TCHAR)c == tc);
} while (c && (FATFS_TCHAR)c == tc);
} while ((c || (tc != '/' && !IsTerminator(tc))) && ++i < FF_VOLUMES); /* Repeat for each ID until pattern match */
if (i < FF_VOLUMES) { /* If a volume ID is found, get the drive number and strip it */
vol = i; /* Drive number */
@ -3330,7 +3330,7 @@ static UINT find_volume ( /* Returns BS status found in the hosting drive */
/*-----------------------------------------------------------------------*/
static FRESULT mount_volume ( /* FR_OK(0): successful, !=0: an error occurred */
const TCHAR** path, /* Pointer to pointer to the path name (drive number) */
const FATFS_TCHAR** path, /* Pointer to pointer to the path name (drive number) */
FATFS** rfs, /* Pointer to pointer to the found filesystem object */
BYTE mode /* !=0: Check write protection for write access */
)
@ -3604,14 +3604,14 @@ static FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */
FRESULT f_mount (
FATFS* fs, /* Pointer to the filesystem object to be registered (NULL:unmount)*/
const TCHAR* path, /* Logical drive number to be mounted/unmounted */
const FATFS_TCHAR* path, /* Logical drive number to be mounted/unmounted */
BYTE opt /* Mount option: 0=Do not mount (delayed mount), 1=Mount immediately */
)
{
FATFS *cfs;
int vol;
FRESULT res;
const TCHAR *rp = path;
const FATFS_TCHAR *rp = path;
/* Get logical drive number */
@ -3652,7 +3652,7 @@ FRESULT f_mount (
FRESULT f_open (
FIL* fp, /* Pointer to the blank file object */
const TCHAR* path, /* Pointer to the file name */
const FATFS_TCHAR* path, /* Pointer to the file name */
BYTE mode /* Access mode and open mode flags */
)
{
@ -4186,7 +4186,7 @@ FRESULT f_close (
/*-----------------------------------------------------------------------*/
FRESULT f_chdrive (
const TCHAR* path /* Drive number to set */
const FATFS_TCHAR* path /* Drive number to set */
)
{
int vol;
@ -4203,7 +4203,7 @@ FRESULT f_chdrive (
FRESULT f_chdir (
const TCHAR* path /* Pointer to the directory path */
const FATFS_TCHAR* path /* Pointer to the directory path */
)
{
#if FF_STR_VOLUME_ID == 2
@ -4265,8 +4265,8 @@ FRESULT f_chdir (
#if FF_FS_RPATH >= 2
FRESULT f_getcwd (
TCHAR* buff, /* Pointer to the directory path */
UINT len /* Size of buff in unit of TCHAR */
FATFS_TCHAR* buff, /* Pointer to the directory path */
UINT len /* Size of buff in unit of FATFS_TCHAR */
)
{
FRESULT res;
@ -4274,7 +4274,7 @@ FRESULT f_getcwd (
FATFS *fs;
UINT i, n;
DWORD ccl;
TCHAR *tp = buff;
FATFS_TCHAR *tp = buff;
#if FF_VOLUMES >= 2
UINT vl;
#if FF_STR_VOLUME_ID
@ -4287,7 +4287,7 @@ FRESULT f_getcwd (
/* Get logical drive */
buff[0] = 0; /* Set null string to get current volume */
res = mount_volume((const TCHAR**)&buff, &fs, 0); /* Get current volume */
res = mount_volume((const FATFS_TCHAR**)&buff, &fs, 0); /* Get current volume */
if (res == FR_OK) {
dj.obj.fs = fs;
INIT_NAMBUF(fs);
@ -4328,15 +4328,15 @@ FRESULT f_getcwd (
#if FF_STR_VOLUME_ID >= 1 /* String volume ID */
for (n = 0, vp = (const char*)VolumeStr[CurrVol]; vp[n]; n++) ;
if (i >= n + 2) {
if (FF_STR_VOLUME_ID == 2) *tp++ = (TCHAR)'/';
for (vl = 0; vl < n; *tp++ = (TCHAR)vp[vl], vl++) ;
if (FF_STR_VOLUME_ID == 1) *tp++ = (TCHAR)':';
if (FF_STR_VOLUME_ID == 2) *tp++ = (FATFS_TCHAR)'/';
for (vl = 0; vl < n; *tp++ = (FATFS_TCHAR)vp[vl], vl++) ;
if (FF_STR_VOLUME_ID == 1) *tp++ = (FATFS_TCHAR)':';
vl++;
}
#else /* Numeric volume ID */
if (i >= 3) {
*tp++ = (TCHAR)'0' + CurrVol;
*tp++ = (TCHAR)':';
*tp++ = (FATFS_TCHAR)'0' + CurrVol;
*tp++ = (FATFS_TCHAR)':';
vl = 2;
}
#endif
@ -4530,7 +4530,7 @@ FRESULT f_lseek (
FRESULT f_opendir (
DIR* dp, /* Pointer to directory object to create */
const TCHAR* path /* Pointer to the directory path */
const FATFS_TCHAR* path /* Pointer to the directory path */
)
{
FRESULT res;
@ -4688,8 +4688,8 @@ FRESULT f_findnext (
FRESULT f_findfirst (
DIR* dp, /* Pointer to the blank directory object */
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 */
const FATFS_TCHAR* path, /* Pointer to the directory to open */
const FATFS_TCHAR* pattern /* Pointer to the matching pattern */
)
{
FRESULT res;
@ -4713,7 +4713,7 @@ FRESULT f_findfirst (
/*-----------------------------------------------------------------------*/
FRESULT f_stat (
const TCHAR* path, /* Pointer to the file path */
const FATFS_TCHAR* path, /* Pointer to the file path */
FILINFO* fno /* Pointer to file information to return */
)
{
@ -4748,7 +4748,7 @@ FRESULT f_stat (
/*-----------------------------------------------------------------------*/
FRESULT f_getfree (
const TCHAR* path, /* Logical drive number */
const FATFS_TCHAR* path, /* Logical drive number */
DWORD* nclst, /* Pointer to a variable to return number of free clusters */
FATFS** fatfs /* Pointer to return pointer to corresponding filesystem object */
)
@ -4890,7 +4890,7 @@ FRESULT f_truncate (
/*-----------------------------------------------------------------------*/
FRESULT f_unlink (
const TCHAR* path /* Pointer to the file or directory path */
const FATFS_TCHAR* path /* Pointer to the file or directory path */
)
{
FRESULT res;
@ -4984,7 +4984,7 @@ FRESULT f_unlink (
/*-----------------------------------------------------------------------*/
FRESULT f_mkdir (
const TCHAR* path /* Pointer to the directory path */
const FATFS_TCHAR* path /* Pointer to the directory path */
)
{
FRESULT res;
@ -5068,8 +5068,8 @@ FRESULT f_mkdir (
/*-----------------------------------------------------------------------*/
FRESULT f_rename (
const TCHAR* path_old, /* Pointer to the object name to be renamed */
const TCHAR* path_new /* Pointer to the new name */
const FATFS_TCHAR* path_old, /* Pointer to the object name to be renamed */
const FATFS_TCHAR* path_new /* Pointer to the new name */
)
{
FRESULT res;
@ -5178,7 +5178,7 @@ FRESULT f_rename (
/*-----------------------------------------------------------------------*/
FRESULT f_chmod (
const TCHAR* path, /* Pointer to the file path */
const FATFS_TCHAR* path, /* Pointer to the file path */
BYTE attr, /* Attribute bits */
BYTE mask /* Attribute mask to change */
)
@ -5225,7 +5225,7 @@ FRESULT f_chmod (
/*-----------------------------------------------------------------------*/
FRESULT f_utime (
const TCHAR* path, /* Pointer to the file/directory name */
const FATFS_TCHAR* path, /* Pointer to the file/directory name */
const FILINFO* fno /* Pointer to the timestamp to be set */
)
{
@ -5272,8 +5272,8 @@ FRESULT f_utime (
/*-----------------------------------------------------------------------*/
FRESULT f_getlabel (
const TCHAR* path, /* Logical drive number */
TCHAR* label, /* Buffer to store the volume label */
const FATFS_TCHAR* path, /* Logical drive number */
FATFS_TCHAR* label, /* Buffer to store the volume label */
DWORD* vsn /* Variable to store the volume serial number */
)
{
@ -5322,7 +5322,7 @@ FRESULT f_getlabel (
if (wc == 0) { di = 0; break; } /* Invalid char in current code page? */
di += put_utf(wc, &label[di], 4); /* Store it in Unicode */
#else /* ANSI/OEM output */
label[di++] = (TCHAR)wc;
label[di++] = (FATFS_TCHAR)wc;
#endif
}
do { /* Truncate trailing spaces */
@ -5369,7 +5369,7 @@ FRESULT f_getlabel (
/*-----------------------------------------------------------------------*/
FRESULT f_setlabel (
const TCHAR* label /* Volume label to set with heading logical drive number */
const FATFS_TCHAR* label /* Volume label to set with heading logical drive number */
)
{
FRESULT res;
@ -5800,7 +5800,7 @@ static FRESULT create_partition (
FRESULT f_mkfs (
const TCHAR* path, /* Logical drive number */
const FATFS_TCHAR* path, /* Logical drive number */
const MKFS_PARM* opt, /* Format options */
void* work, /* Pointer to working buffer (null: use heap memory) */
UINT len /* Size of working buffer [byte] */
@ -6335,14 +6335,14 @@ FRESULT f_fdisk (
/* Get a String from the File */
/*-----------------------------------------------------------------------*/
TCHAR* f_gets (
TCHAR* buff, /* Pointer to the buffer to store read string */
FATFS_TCHAR* f_gets (
FATFS_TCHAR* buff, /* Pointer to the buffer to store read string */
int len, /* Size of string buffer (items) */
FIL* fp /* Pointer to the file object */
)
{
int nc = 0;
TCHAR *p = buff;
FATFS_TCHAR *p = buff;
BYTE s[4];
UINT rc;
DWORD dc;
@ -6407,32 +6407,32 @@ TCHAR* f_gets (
if (FF_USE_STRFUNC == 2 && dc == '\r') continue; /* Strip \r off if needed */
#if FF_LFN_UNICODE == 1 || FF_LFN_UNICODE == 3 /* Output it in UTF-16/32 encoding */
if (FF_LFN_UNICODE == 1 && dc >= 0x10000) { /* Out of BMP at UTF-16? */
*p++ = (TCHAR)(0xD800 | ((dc >> 10) - 0x40)); nc++; /* Make and output high surrogate */
*p++ = (FATFS_TCHAR)(0xD800 | ((dc >> 10) - 0x40)); nc++; /* Make and output high surrogate */
dc = 0xDC00 | (dc & 0x3FF); /* Make low surrogate */
}
*p++ = (TCHAR)dc; nc++;
*p++ = (FATFS_TCHAR)dc; nc++;
if (dc == '\n') break; /* End of line? */
#elif FF_LFN_UNICODE == 2 /* Output it in UTF-8 encoding */
if (dc < 0x80) { /* Single byte? */
*p++ = (TCHAR)dc;
*p++ = (FATFS_TCHAR)dc;
nc++;
if (dc == '\n') break; /* End of line? */
} else {
if (dc < 0x800) { /* 2-byte sequence? */
*p++ = (TCHAR)(0xC0 | (dc >> 6 & 0x1F));
*p++ = (TCHAR)(0x80 | (dc >> 0 & 0x3F));
*p++ = (FATFS_TCHAR)(0xC0 | (dc >> 6 & 0x1F));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 0 & 0x3F));
nc += 2;
} else {
if (dc < 0x10000) { /* 3-byte sequence? */
*p++ = (TCHAR)(0xE0 | (dc >> 12 & 0x0F));
*p++ = (TCHAR)(0x80 | (dc >> 6 & 0x3F));
*p++ = (TCHAR)(0x80 | (dc >> 0 & 0x3F));
*p++ = (FATFS_TCHAR)(0xE0 | (dc >> 12 & 0x0F));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 6 & 0x3F));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 0 & 0x3F));
nc += 3;
} else { /* 4-byte sequence? */
*p++ = (TCHAR)(0xF0 | (dc >> 18 & 0x07));
*p++ = (TCHAR)(0x80 | (dc >> 12 & 0x3F));
*p++ = (TCHAR)(0x80 | (dc >> 6 & 0x3F));
*p++ = (TCHAR)(0x80 | (dc >> 0 & 0x3F));
*p++ = (FATFS_TCHAR)(0xF0 | (dc >> 18 & 0x07));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 12 & 0x3F));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 6 & 0x3F));
*p++ = (FATFS_TCHAR)(0x80 | (dc >> 0 & 0x3F));
nc += 4;
}
}
@ -6447,7 +6447,7 @@ TCHAR* f_gets (
if (rc != 1) break; /* EOF? */
dc = s[0];
if (FF_USE_STRFUNC == 2 && dc == '\r') continue;
*p++ = (TCHAR)dc; nc++;
*p++ = (FATFS_TCHAR)dc; nc++;
if (dc == '\n') break;
}
#endif
@ -6485,7 +6485,7 @@ typedef struct {
/* Buffered file write with code conversion */
static void putc_bfd (putbuff* pb, TCHAR c)
static void putc_bfd (putbuff* pb, FATFS_TCHAR c)
{
UINT n;
int i, nc;
@ -6493,7 +6493,7 @@ static void putc_bfd (putbuff* pb, TCHAR c)
WCHAR hs, wc;
#if FF_LFN_UNICODE == 2
DWORD dc;
const TCHAR *tp;
const FATFS_TCHAR *tp;
#endif
#endif
@ -6535,7 +6535,7 @@ static void putc_bfd (putbuff* pb, TCHAR c)
return;
}
}
tp = (const TCHAR*)pb->bs;
tp = (const FATFS_TCHAR*)pb->bs;
dc = tchar2uni(&tp); /* UTF-8 ==> UTF-16 */
if (dc == 0xFFFFFFFF) return; /* Wrong code? */
wc = (WCHAR)dc;
@ -6638,7 +6638,7 @@ static void putc_init (putbuff* pb, FIL* fp)
int f_putc (
TCHAR c, /* A character to be output */
FATFS_TCHAR c, /* A character to be output */
FIL* fp /* Pointer to the file object */
)
{
@ -6658,7 +6658,7 @@ int f_putc (
/*-----------------------------------------------------------------------*/
int f_puts (
const TCHAR* str, /* Pointer to the string to be output */
const FATFS_TCHAR* str, /* Pointer to the string to be output */
FIL* fp /* Pointer to the file object */
)
{
@ -6727,7 +6727,7 @@ static void ftoa (
char* buf, /* Buffer to output the floating point string */
double val, /* Value to output */
int prec, /* Number of fractional digits */
TCHAR fmt /* Notation */
FATFS_TCHAR fmt /* Notation */
)
{
int d;
@ -6800,7 +6800,7 @@ static void ftoa (
int f_printf (
FIL* fp, /* Pointer to the file object */
const TCHAR* fmt, /* Pointer to the format string */
const FATFS_TCHAR* fmt, /* Pointer to the format string */
... /* Optional arguments... */
)
{
@ -6813,8 +6813,8 @@ int f_printf (
#else
DWORD v;
#endif
TCHAR tc, pad, *tp;
TCHAR nul = 0;
FATFS_TCHAR tc, pad, *tp;
FATFS_TCHAR nul = 0;
char d, str[SZ_NUM_BUF];
@ -6879,10 +6879,10 @@ int f_printf (
case 'X': /* Unsigned hexdecimal (upper case) */
r = 16; break;
case 'c': /* Character */
putc_bfd(&pb, (TCHAR)va_arg(arp, int));
putc_bfd(&pb, (FATFS_TCHAR)va_arg(arp, int));
continue;
case 's': /* String */
tp = va_arg(arp, TCHAR*); /* Get a pointer argument */
tp = va_arg(arp, FATFS_TCHAR*); /* Get a pointer argument */
if (!tp) tp = &nul; /* Null ptr generates a null string */
for (j = 0; tp[j]; j++) ; /* j = tcslen(tp) */
if (prec >= 0 && j > (UINT)prec) j = prec; /* Limited length of string body */
@ -6937,7 +6937,7 @@ int f_printf (
if (f & 1) str[i++] = '-'; /* Sign */
/* Write it */
for (j = i; !(f & 2) && j < w; j++) putc_bfd(&pb, pad); /* Left pads */
do putc_bfd(&pb, (TCHAR)str[--i]); while (i); /* Body */
do putc_bfd(&pb, (FATFS_TCHAR)str[--i]); while (i); /* Body */
while (j++ < w) putc_bfd(&pb, ' '); /* Right pads */
}

76
Externals/FatFs/ff.h vendored
View File

@ -85,26 +85,26 @@ typedef DWORD LBA_t;
/* Type of path name strings on FatFs API (TCHAR) */
/* Type of path name strings on FatFs API (FATFS_TCHAR) */
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
typedef WCHAR TCHAR;
#define _T(x) L ## x
#define _TEXT(x) L ## x
typedef WCHAR FATFS_TCHAR;
#define FATFS__T(x) L ## x
#define FATFS__TEXT(x) L ## x
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
typedef char TCHAR;
#define _T(x) u8 ## x
#define _TEXT(x) u8 ## x
typedef char FATFS_TCHAR;
#define FATFS__T(x) u8 ## x
#define FATFS__TEXT(x) u8 ## x
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
typedef DWORD TCHAR;
#define _T(x) U ## x
#define _TEXT(x) U ## x
typedef DWORD FATFS_TCHAR;
#define FATFS__T(x) U ## x
#define FATFS__TEXT(x) U ## x
#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)
#error Wrong FF_LFN_UNICODE setting
#else /* ANSI/OEM code in SBCS/DBCS */
typedef char TCHAR;
#define _T(x) x
#define _TEXT(x) x
typedef char FATFS_TCHAR;
#define FATFS__T(x) x
#define FATFS__TEXT(x) x
#endif
@ -236,7 +236,7 @@ typedef struct {
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
#endif
#if FF_USE_FIND
const TCHAR* pat; /* Pointer to the name matching pattern */
const FATFS_TCHAR* pat; /* Pointer to the name matching pattern */
#endif
} DIR;
@ -250,10 +250,10 @@ typedef struct {
WORD ftime; /* Modified time */
BYTE fattrib; /* File attribute */
#if FF_USE_LFN
TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
FATFS_TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
FATFS_TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
#else
TCHAR fname[12 + 1]; /* File name */
FATFS_TCHAR fname[12 + 1]; /* File name */
#endif
} FILINFO;
@ -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_open (FIL* fp, const FATFS_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 (DIR* dp, const TCHAR* path); /* Open a directory */
FRESULT f_opendir (DIR* dp, const FATFS_TCHAR* path); /* Open a directory */
FRESULT f_closedir (DIR* dp); /* Close an open directory */
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const FATFS_TCHAR* path, const FATFS_TCHAR* pattern); /* Find first file */
FRESULT f_findnext (DIR* dp, 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_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_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_mkdir (const FATFS_TCHAR* path); /* Create a sub directory */
FRESULT f_unlink (const FATFS_TCHAR* path); /* Delete an existing file or directory */
FRESULT f_rename (const FATFS_TCHAR* path_old, const FATFS_TCHAR* path_new); /* Rename/Move a file or directory */
FRESULT f_stat (const FATFS_TCHAR* path, FILINFO* fno); /* Get file status */
FRESULT f_chmod (const FATFS_TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
FRESULT f_utime (const FATFS_TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
FRESULT f_chdir (const FATFS_TCHAR* path); /* Change current directory */
FRESULT f_chdrive (const FATFS_TCHAR* path); /* Change current drive */
FRESULT f_getcwd (FATFS_TCHAR* buff, UINT len); /* Get current directory */
FRESULT f_getfree (const FATFS_TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
FRESULT f_getlabel (const FATFS_TCHAR* path, FATFS_TCHAR* label, DWORD* vsn); /* Get volume label */
FRESULT f_setlabel (const FATFS_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_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_mount (FATFS* fs, const FATFS_TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
FRESULT f_mkfs (const FATFS_TCHAR* path, const 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 (FATFS_TCHAR c, FIL* fp); /* Put a character to the file */
int f_puts (const FATFS_TCHAR* str, FIL* cp); /* Put a string to the file */
int f_printf (FIL* fp, const FATFS_TCHAR* str, ...); /* Put a formatted string to the file */
FATFS_TCHAR* f_gets (FATFS_TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
#define f_error(fp) ((fp)->err)