aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadia Holmquist Pedersen <nadia@nhp.sh>2023-12-11 10:56:09 +0100
committerNadia Holmquist Pedersen <nadia@nhp.sh>2023-12-11 10:59:05 +0100
commit81219a9f5d60d0e9c92a4c6cec279b087aae053d (patch)
treeba05c8953c369f825f79588d684f7502fc97852b
parent082310d5d5437bde589a99849f4cfacb58b1af53 (diff)
Fix some conflicts with windows.h in some configurations
Fixes build in the MSYS2 Clang/ClangARM64 environments.
-rw-r--r--src/fatfs/ff.c186
-rw-r--r--src/fatfs/ff.h60
-rw-r--r--src/fatfs/ffsystem.c4
-rw-r--r--src/frontend/qt_sdl/LocalMP.cpp2
4 files changed, 128 insertions, 124 deletions
diff --git a/src/fatfs/ff.c b/src/fatfs/ff.c
index 9d21294..385da84 100644
--- a/src/fatfs/ff.c
+++ b/src/fatfs/ff.c
@@ -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 FF_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 FF_TCHAR** str /* Pointer to pointer to FF_TCHAR string in configured encoding */
)
{
DWORD uc;
- const TCHAR *p = *str;
+ const FF_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 = (FF_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 */
+ FF_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 = (FF_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++ = (FF_TCHAR)(0xC0 | (chr >> 6 & 0x1F));
+ *buf++ = (FF_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++ = (FF_TCHAR)(0xE0 | (chr >> 12 & 0x0F));
+ *buf++ = (FF_TCHAR)(0x80 | (chr >> 6 & 0x3F));
+ *buf++ = (FF_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++ = (FF_TCHAR)(0xF0 | (chr >> 18 & 0x07));
+ *buf++ = (FF_TCHAR)(0x80 | (chr >> 12 & 0x3F));
+ *buf++ = (FF_TCHAR)(0x80 | (chr >> 6 & 0x3F));
+ *buf++ = (FF_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++ = (FF_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++ = (FF_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++ = (FF_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;
+ FF_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++] = (FF_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] = (FF_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 = (FF_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 FF_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 FF_TCHAR* pat, /* Matching pattern */
+ const FF_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 FF_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 */
FF_DIR* dp, /* Pointer to the directory object */
- const TCHAR** path /* Pointer to pointer to the segment in the path string */
+ const FF_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 FF_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 */
FF_DIR* dp, /* Directory object to return last directory and found object */
- const TCHAR* path /* Full-path string to find a file or directory */
+ const FF_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 FF_TCHAR** path /* Pointer to pointer to the path name */
)
{
- const TCHAR *tp, *tt;
- TCHAR tc;
+ const FF_TCHAR *tp, *tt;
+ FF_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 && (FF_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 && (FF_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 FF_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 FF_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 FF_TCHAR *rp = path;
/* Get logical drive number */
@@ -3652,7 +3652,7 @@ FRESULT f_mount (
FRESULT f_open (
FF_FIL* fp, /* Pointer to the blank file object */
- const TCHAR* path, /* Pointer to the file name */
+ const FF_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 FF_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 FF_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 */
+ FF_TCHAR* buff, /* Pointer to the directory path */
+ UINT len /* Size of buff in unit of FF_TCHAR */
)
{
FRESULT res;
@@ -4274,7 +4274,7 @@ FRESULT f_getcwd (
FATFS *fs;
UINT i, n;
DWORD ccl;
- TCHAR *tp = buff;
+ FF_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 FF_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++ = (FF_TCHAR)'/';
+ for (vl = 0; vl < n; *tp++ = (FF_TCHAR)vp[vl], vl++) ;
+ if (FF_STR_VOLUME_ID == 1) *tp++ = (FF_TCHAR)':';
vl++;
}
#else /* Numeric volume ID */
if (i >= 3) {
- *tp++ = (TCHAR)'0' + CurrVol;
- *tp++ = (TCHAR)':';
+ *tp++ = (FF_TCHAR)'0' + CurrVol;
+ *tp++ = (FF_TCHAR)':';
vl = 2;
}
#endif
@@ -4530,7 +4530,7 @@ FRESULT f_lseek (
FRESULT f_opendir (
FF_DIR* dp, /* Pointer to directory object to create */
- const TCHAR* path /* Pointer to the directory path */
+ const FF_TCHAR* path /* Pointer to the directory path */
)
{
FRESULT res;
@@ -4688,8 +4688,8 @@ FRESULT f_findnext (
FRESULT f_findfirst (
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 */
+ const FF_TCHAR* path, /* Pointer to the directory to open */
+ const FF_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 FF_TCHAR* path, /* Pointer to the file path */
FF_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 FF_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 FF_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 FF_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 FF_TCHAR* path_old, /* Pointer to the object name to be renamed */
+ const FF_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 FF_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 FF_TCHAR* path, /* Pointer to the file/directory name */
const FF_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 FF_TCHAR* path, /* Logical drive number */
+ FF_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++] = (FF_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 FF_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 FF_TCHAR* path, /* Logical drive number */
const FF_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 */
+FF_TCHAR* f_gets (
+ FF_TCHAR* buff, /* Pointer to the buffer to store read string */
int len, /* Size of string buffer (items) */
FF_FIL* fp /* Pointer to the file object */
)
{
int nc = 0;
- TCHAR *p = buff;
+ FF_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++ = (FF_TCHAR)(0xD800 | ((dc >> 10) - 0x40)); nc++; /* Make and output high surrogate */
dc = 0xDC00 | (dc & 0x3FF); /* Make low surrogate */
}
- *p++ = (TCHAR)dc; nc++;
+ *p++ = (FF_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++ = (FF_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++ = (FF_TCHAR)(0xC0 | (dc >> 6 & 0x1F));
+ *p++ = (FF_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++ = (FF_TCHAR)(0xE0 | (dc >> 12 & 0x0F));
+ *p++ = (FF_TCHAR)(0x80 | (dc >> 6 & 0x3F));
+ *p++ = (FF_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++ = (FF_TCHAR)(0xF0 | (dc >> 18 & 0x07));
+ *p++ = (FF_TCHAR)(0x80 | (dc >> 12 & 0x3F));
+ *p++ = (FF_TCHAR)(0x80 | (dc >> 6 & 0x3F));
+ *p++ = (FF_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++ = (FF_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, FF_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 FF_TCHAR *tp;
#endif
#endif
@@ -6535,7 +6535,7 @@ static void putc_bfd (putbuff* pb, TCHAR c)
return;
}
}
- tp = (const TCHAR*)pb->bs;
+ tp = (const FF_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, FF_FIL* fp)
int f_putc (
- TCHAR c, /* A character to be output */
+ FF_TCHAR c, /* A character to be output */
FF_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 FF_TCHAR* str, /* Pointer to the string to be output */
FF_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 */
+ FF_TCHAR fmt /* Notation */
)
{
int d;
@@ -6800,7 +6800,7 @@ static void ftoa (
int f_printf (
FF_FIL* fp, /* Pointer to the file object */
- const TCHAR* fmt, /* Pointer to the format string */
+ const FF_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;
+ FF_TCHAR tc, pad, *tp;
+ FF_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, (FF_TCHAR)va_arg(arp, int));
continue;
case 's': /* String */
- tp = va_arg(arp, TCHAR*); /* Get a pointer argument */
+ tp = va_arg(arp, FF_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, (FF_TCHAR)str[--i]); while (i); /* Body */
while (j++ < w) putc_bfd(&pb, ' '); /* Right pads */
}
diff --git a/src/fatfs/ff.h b/src/fatfs/ff.h
index c2832be..1662d83 100644
--- a/src/fatfs/ff.h
+++ b/src/fatfs/ff.h
@@ -85,24 +85,24 @@ typedef DWORD LBA_t;
-/* Type of path name strings on FatFs API (TCHAR) */
+/* Type of path name strings on FatFs API (FF_TCHAR) */
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
-typedef WCHAR TCHAR;
+typedef WCHAR FF_TCHAR;
#define _T(x) L ## x
#define _TEXT(x) L ## x
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
-typedef char TCHAR;
+typedef char FF_TCHAR;
#define _T(x) u8 ## x
#define _TEXT(x) u8 ## x
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
-typedef DWORD TCHAR;
+typedef DWORD FF_TCHAR;
#define _T(x) U ## x
#define _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;
+typedef char FF_TCHAR;
#define _T(x) x
#define _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 FF_TCHAR* pat; /* Pointer to the name matching pattern */
#endif
} FF_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 */
+ FF_TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
+ FF_TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
#else
- TCHAR fname[12 + 1]; /* File name */
+ FF_TCHAR fname[12 + 1]; /* File name */
#endif
} FF_FILINFO;
@@ -301,40 +301,40 @@ typedef enum {
/*--------------------------------------------------------------*/
/* FatFs module application interface */
-FRESULT f_open (FF_FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
+FRESULT f_open (FF_FIL* fp, const FF_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_opendir (FF_DIR* dp, const FF_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_findfirst (FF_DIR* dp, FF_FILINFO* fno, const FF_TCHAR* path, const FF_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, 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 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_mkdir (const FF_TCHAR* path); /* Create a sub directory */
+FRESULT f_unlink (const FF_TCHAR* path); /* Delete an existing file or directory */
+FRESULT f_rename (const FF_TCHAR* path_old, const FF_TCHAR* path_new); /* Rename/Move a file or directory */
+FRESULT f_stat (const FF_TCHAR* path, FF_FILINFO* fno); /* Get file status */
+FRESULT f_chmod (const FF_TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
+FRESULT f_utime (const FF_TCHAR* path, const FF_FILINFO* fno); /* Change timestamp of a file/dir */
+FRESULT f_chdir (const FF_TCHAR* path); /* Change current directory */
+FRESULT f_chdrive (const FF_TCHAR* path); /* Change current drive */
+FRESULT f_getcwd (FF_TCHAR* buff, UINT len); /* Get current directory */
+FRESULT f_getfree (const FF_TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
+FRESULT f_getlabel (const FF_TCHAR* path, FF_TCHAR* label, DWORD* vsn); /* Get volume label */
+FRESULT f_setlabel (const FF_TCHAR* label); /* Set volume label */
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 FF_MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
+FRESULT f_mount (FATFS* fs, const FF_TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
+FRESULT f_mkfs (const FF_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, 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 */
+int f_putc (FF_TCHAR c, FF_FIL* fp); /* Put a character to the file */
+int f_puts (const FF_TCHAR* str, FF_FIL* cp); /* Put a string to the file */
+int f_printf (FF_FIL* fp, const FF_TCHAR* str, ...); /* Put a formatted string to the file */
+FF_TCHAR* f_gets (FF_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)
diff --git a/src/fatfs/ffsystem.c b/src/fatfs/ffsystem.c
index 63fedf6..ebde84a 100644
--- a/src/fatfs/ffsystem.c
+++ b/src/fatfs/ffsystem.c
@@ -110,7 +110,11 @@ DWORD get_fattime(void)
time_t timestamp = time(NULL);
struct tm timedata;
+#if defined(_MSC_VER)
+ localtime_s(&timedata, &timestamp);
+#else
localtime_r(&timestamp, &timedata);
+#endif
DWORD ret;
ret = (timedata.tm_sec >> 1);
diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp
index c69537a..466f90c 100644
--- a/src/frontend/qt_sdl/LocalMP.cpp
+++ b/src/frontend/qt_sdl/LocalMP.cpp
@@ -130,7 +130,7 @@ bool SemInit(int num)
char semname[64];
sprintf(semname, "Local\\melonNIFI_Sem%02d", num);
- HANDLE sem = CreateSemaphore(nullptr, 0, 64, semname);
+ HANDLE sem = CreateSemaphoreA(nullptr, 0, 64, semname);
SemPool[num] = sem;
SemInited[num] = true;
return sem != INVALID_HANDLE_VALUE;