137 #error Wrong include file (ff.h). 144 #error Static LFN work area cannot be used at thread-safe configuration 146 #define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } 147 #define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } 150 #define LEAVE_FF(fs, res) return res 153 #define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } 157 #if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) 158 #error Wrong sector size configuration 160 #if _MAX_SS == _MIN_SS 161 #define SS(fs) ((UINT)_MAX_SS) 163 #define SS(fs) ((fs)->ssize) 169 #if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 170 #error Invalid _FS_NORTC settings 172 #define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) 174 #define GET_FATTIME() get_fattime() 181 #error _FS_LOCK must be 0 at read-only configuration 195 #if _CODE_PAGE == 932 205 #elif _CODE_PAGE == 936 213 #elif _CODE_PAGE == 949 223 #elif _CODE_PAGE == 950 231 #elif _CODE_PAGE == 437 233 #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 234 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0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DB,0xDC,0xDD,0xDE,0xDF, \ 299 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 301 #elif _CODE_PAGE == 866 303 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 304 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 305 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 306 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 308 #elif _CODE_PAGE == 874 310 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 311 0xA0,0xA1,0xA2,0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0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 376 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} 378 #elif _CODE_PAGE == 1 380 #error Cannot use LFN feature without valid code page. 385 #error Unknown code page 391 #define IsUpper(c) (((c)>='A')&&((c)<='Z')) 392 #define IsLower(c) (((c)>='a')&&((c)<='z')) 393 #define IsDigit(c) (((c)>='0')&&((c)<='9')) 398 #define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) 400 #define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) 404 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) 406 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) 428 #define MIN_FAT16 4086U 429 #define MIN_FAT32 65526U 438 #define BPB_BytsPerSec 11 439 #define BPB_SecPerClus 13 440 #define BPB_RsvdSecCnt 14 441 #define BPB_NumFATs 16 442 #define BPB_RootEntCnt 17 443 #define BPB_TotSec16 19 445 #define BPB_FATSz16 22 446 #define BPB_SecPerTrk 24 447 #define BPB_NumHeads 26 448 #define BPB_HiddSec 28 449 #define BPB_TotSec32 32 451 #define BS_BootSig 38 454 #define BS_FilSysType 54 455 #define BPB_FATSz32 36 456 #define BPB_ExtFlags 40 458 #define BPB_RootClus 44 459 #define BPB_FSInfo 48 460 #define BPB_BkBootSec 50 461 #define BS_DrvNum32 64 462 #define BS_BootSig32 66 463 #define BS_VolID32 67 464 #define BS_VolLab32 71 465 #define BS_FilSysType32 82 466 #define FSI_LeadSig 0 467 #define FSI_StrucSig 484 468 #define FSI_Free_Count 488 469 #define FSI_Nxt_Free 492 470 #define MBR_Table 446 477 #define DIR_CrtTimeTenth 13 478 #define DIR_CrtTime 14 479 #define DIR_CrtDate 16 480 #define DIR_LstAccDate 18 481 #define DIR_FstClusHI 20 482 #define DIR_WrtTime 22 483 #define DIR_WrtDate 24 484 #define DIR_FstClusLO 26 485 #define DIR_FileSize 28 489 #define LDIR_Chksum 13 490 #define LDIR_FstClusLO 26 507 #if _VOLUMES < 1 || _VOLUMES > 9 508 #error Wrong _VOLUMES setting 513 #if _FS_RPATH && _VOLUMES >= 2 522 #define DEFINE_NAMEBUF BYTE sfn[12] 523 #define INIT_BUF(dobj) (dobj).fn = sfn 526 #if _MAX_LFN < 12 || _MAX_LFN > 255 527 #error Wrong _MAX_LFN setting 531 #define DEFINE_NAMEBUF BYTE sfn[12] 532 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } 535 #define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1] 536 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } 539 #define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn 540 #define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } 541 #define FREE_BUF() ff_memfree(lfn) 543 #error Wrong _USE_LFN setting 548 static const BYTE ExCvt[] = _EXCVT;
569 static void gen_numname (
BYTE* dst,
const BYTE* src,
const WCHAR* lfn,
UINT seq);
580 void mem_cpy (
void* dst,
const void* src,
UINT cnt) {
584 #if _WORD_ACCESS == 1 585 while (cnt >=
sizeof (
int)) {
587 d +=
sizeof (int); s +=
sizeof (int);
597 void mem_set (
void* dst,
int val,
UINT cnt) {
606 int mem_cmp (
const void* dst,
const void* src,
UINT cnt) {
607 const BYTE *d = (
const BYTE *)dst, *s = (
const BYTE *)src;
610 while (cnt-- && (r = *d++ - *s++) == 0) ;
616 int chk_chr (
const char* str,
int chr) {
617 while (*str && *str != chr) str++;
633 return ff_req_grant(fs->sobj);
648 ff_rel_grant(fs->sobj);
670 for (i = be = 0; i <
_FS_LOCK; i++) {
672 if (Files[i].fs == dp->
fs &&
673 Files[i].clu == dp->
sclust &&
674 Files[i].idx == dp->
index)
break;
692 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
693 return (i == _FS_LOCK) ? 0 : 1;
707 if (Files[i].fs == dp->
fs &&
708 Files[i].clu == dp->
sclust &&
709 Files[i].idx == dp->
index)
break;
713 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
714 if (i == _FS_LOCK)
return 0;
715 Files[i].fs = dp->
fs;
716 Files[i].clu = dp->
sclust;
717 Files[i].idx = dp->
index;
721 if (acc && Files[i].ctr)
return 0;
723 Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1;
738 if (--i < _FS_LOCK) {
740 if (n == 0x100) n = 0;
743 if (!n) Files[i].fs = 0;
760 if (Files[i].fs == fs) Files[i].fs = 0;
789 for (nf = fs->
n_fats; nf >= 2; nf--) {
812 res = sync_window(fs);
840 res = sync_window(fs);
845 mem_set(fs->
win.
d8, 0,
SS(fs));
879 if (clst >= fs->
n_fatent - 2)
return 0;
901 if (clst < 2 || clst >= fs->
n_fatent) {
909 bc = (
UINT)clst; bc += bc / 2;
911 wc = fs->
win.
d8[bc++ %
SS(fs)];
913 wc |= fs->
win.
d8[bc %
SS(fs)] << 8;
914 val = clst & 1 ? wc >> 4 : (wc & 0xFFF);
918 if (move_window(fs, fs->
fatbase + (clst / (
SS(fs) / 2))) !=
FR_OK)
break;
919 p = &fs->
win.
d8[clst * 2 %
SS(fs)];
924 if (move_window(fs, fs->
fatbase + (clst / (
SS(fs) / 4))) !=
FR_OK)
break;
925 p = &fs->
win.
d8[clst * 4 %
SS(fs)];
957 if (clst < 2 || clst >= fs->
n_fatent) {
963 bc = (
UINT)clst; bc += bc / 2;
964 res = move_window(fs, fs->
fatbase + (bc /
SS(fs)));
965 if (res !=
FR_OK)
break;
966 p = &fs->
win.
d8[bc++ %
SS(fs)];
967 *p = (clst & 1) ? ((*p & 0x0F) | ((
BYTE)val << 4)) : (
BYTE)val;
969 res = move_window(fs, fs->
fatbase + (bc /
SS(fs)));
970 if (res !=
FR_OK)
break;
972 *p = (clst & 1) ? (
BYTE)(val >> 4) : ((*p & 0xF0) | ((
BYTE)(val >> 8) & 0x0F));
977 res = move_window(fs, fs->
fatbase + (clst / (
SS(fs) / 2)));
978 if (res !=
FR_OK)
break;
979 p = &fs->
win.
d8[clst * 2 %
SS(fs)];
985 res = move_window(fs, fs->
fatbase + (clst / (
SS(fs) / 4)));
986 if (res !=
FR_OK)
break;
987 p = &fs->
win.
d8[clst * 4 %
SS(fs)];
1018 DWORD scl = clst, ecl = clst, rt[2];
1021 if (clst < 2 || clst >= fs->
n_fatent) {
1026 while (clst < fs->n_fatent) {
1028 if (nxt == 0)
break;
1030 if (nxt == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
1032 if (res !=
FR_OK)
break;
1038 if (ecl + 1 == nxt) {
1063 DWORD create_chain (
1074 if (!scl || scl >= fs->
n_fatent) scl = 1;
1078 if (cs < 2)
return 1;
1079 if (cs == 0xFFFFFFFF)
return cs;
1080 if (cs < fs->n_fatent)
return cs;
1089 if (ncl > scl)
return 0;
1093 if (cs == 0xFFFFFFFF || cs == 1)
1095 if (ncl == scl)
return 0;
1098 res =
put_fat(fs, ncl, 0x0FFFFFFF);
1099 if (res ==
FR_OK && clst != 0) {
1130 DWORD cl, ncl, *tbl;
1133 tbl = fp->cltbl + 1;
1138 if (cl < ncl)
break;
1214 if (!(i & 0xFFFF) || !dp->
sect)
1232 clst = create_chain(dp->
fs, dp->
clust);
1240 for (c = 0; c < dp->
fs->
csize; c++) {
1281 res = dir_sdi(dp, 0);
1285 res = move_window(dp->
fs, dp->
sect);
1286 if (res !=
FR_OK)
break;
1288 if (++n == nent)
break;
1292 res = dir_next(dp, 1);
1293 }
while (res ==
FR_OK);
1343 const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
1359 uc =
LD_WORD(dir + LfnOfs[s]);
1365 if (uc != 0xFFFF)
return 0;
1387 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1391 uc =
LD_WORD(dir + LfnOfs[s]);
1394 lfnbuf[i++] = wc = uc;
1396 if (uc != 0xFFFF)
return 0;
1412 const WCHAR* lfnbuf,
1430 if (wc != 0xFFFF) wc = lfnbuf[i++];
1432 if (!wc) wc = 0xFFFF;
1434 if (wc == 0xFFFF || !lfnbuf[i]) ord |=
LLEF;
1462 mem_cpy(dst, src, 11);
1468 for (i = 0; i < 16; i++) {
1469 sr = (sr << 1) + (wc & 1);
1471 if (sr & 0x10000) sr ^= 0x11021;
1480 c = (seq % 16) +
'0';
1481 if (c >
'9') c += 7;
1488 for (j = 0; j < i && dst[j] !=
' '; j++) {
1490 if (j == i - 1)
break;
1495 dst[j++] = (i < 8) ? ns[i++] :
' ';
1515 do sum = (sum >> 1) + (sum << 7) + *dir++;
while (--n);
1538 res = dir_sdi(dp, 0);
1539 if (res !=
FR_OK)
return res;
1542 ord = sum = 0xFF; dp->lfn_idx = 0xFFFF;
1545 res = move_window(dp->
fs, dp->
sect);
1546 if (res !=
FR_OK)
break;
1553 ord = 0xFF; dp->lfn_idx = 0xFFFF;
1559 c &= ~LLEF; ord = c;
1560 dp->lfn_idx = dp->
index;
1563 ord = (c == ord && sum == dir[
LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
1566 if (!ord && sum == sum_sfn(dir))
break;
1568 ord = 0xFF; dp->lfn_idx = 0xFFFF;
1572 if (!(dir[
DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->
fn, 11))
1575 res = dir_next(dp, 0);
1576 }
while (res ==
FR_OK);
1587 #if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 1597 BYTE ord = 0xFF, sum = 0xFF;
1602 res = move_window(dp->
fs, dp->
sect);
1603 if (res !=
FR_OK)
break;
1615 c &= ~LLEF; ord = c;
1616 dp->lfn_idx = dp->
index;
1619 ord = (c == ord && sum == dir[
LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
1621 if (ord || sum != sum_sfn(dir))
1622 dp->lfn_idx = 0xFFFF;
1630 res = dir_next(dp, 0);
1631 if (res !=
FR_OK)
break;
1655 BYTE sn[12], *fn, sum;
1659 fn = dp->
fn; lfn = dp->lfn;
1660 mem_cpy(sn, fn, 12);
1666 fn[
NSFLAG] = 0; dp->lfn = 0;
1667 for (n = 1; n < 100; n++) {
1668 gen_numname(fn, sn, lfn, n);
1670 if (res !=
FR_OK)
break;
1678 for (n = 0; lfn[n]; n++) ;
1679 nent = (n + 25) / 13;
1683 res = dir_alloc(dp, nent);
1685 if (res ==
FR_OK && --nent) {
1686 res = dir_sdi(dp, dp->
index - nent);
1688 sum = sum_sfn(dp->
fn);
1690 res = move_window(dp->
fs, dp->
sect);
1691 if (res !=
FR_OK)
break;
1692 fit_lfn(dp->lfn, dp->
dir, (
BYTE)nent, sum);
1694 res = dir_next(dp, 0);
1695 }
while (res ==
FR_OK && --nent);
1699 res = dir_alloc(dp, 1);
1703 res = move_window(dp->
fs, dp->
sect);
1706 mem_cpy(dp->
dir, dp->
fn, 11);
1724 #if !_FS_READONLY && !_FS_MINIMIZE 1735 res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx);
1738 res = move_window(dp->
fs, dp->
sect);
1739 if (res !=
FR_OK)
break;
1743 if (dp->
index >= i)
break;
1744 res = dir_next(dp, 0);
1745 }
while (res ==
FR_OK);
1750 res = dir_sdi(dp, dp->
index);
1752 res = move_window(dp->
fs, dp->
sect);
1771 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 1790 c = (
TCHAR)dir[i++];
1791 if (c ==
' ')
continue;
1793 if (i == 9) *p++ =
'.';
1799 c = c << 8 | dir[i++];
1815 i = 0; p = fno->lfname;
1816 if (dp->
sect && fno->lfsize && dp->lfn_idx != 0xFFFF) {
1818 while ((w = *lfn++) != 0) {
1821 if (!w) { i = 0;
break; }
1822 if (_DF1S && w >= 0x100)
1823 p[i++] = (
TCHAR)(w >> 8);
1825 if (i >= fno->lfsize - 1) { i = 0;
break; }
1841 #if _USE_FIND && _FS_MINIMIZE <= 1 1850 chr = (
BYTE)*(*ptr)++;
1851 if (
IsLower(chr)) chr -= 0x20;
1853 chr = chr << 8 | (
BYTE)*(*ptr)++;
1855 if (chr >= 0x80) chr = ExCvt[chr - 0x80];
1865 int pattern_matching (
1872 const TCHAR *pp, *np;
1878 if (!get_achar(&nam))
return 0;
1880 if (!*pat && inf)
return 1;
1885 if (*pp ==
'?' || *pp ==
'*') {
1888 if (*pp++ ==
'?') nm++;
else nx = 1;
1889 }
while (*pp ==
'?' || *pp ==
'*');
1890 if (pattern_matching(pp, np, nm, nx))
return 1;
1893 pc = get_achar(&pp);
1894 nc = get_achar(&np);
1895 if (pc != nc)
break;
1899 }
while (inf && nc);
1925 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
1930 if (w <
' ' || w ==
'/' || w ==
'\\')
break;
1946 if (w < 0x80 && chk_chr(
"\"*:<>\?|\x7F", w))
1953 if ((di == 1 && lfn[di - 1] ==
'.') ||
1954 (di == 2 && lfn[di - 1] ==
'.' && lfn[di - 2] ==
'.')) {
1956 for (i = 0; i < 11; i++)
1957 dp->
fn[i] = (i < di) ?
'.' :
' ';
1964 if (w !=
' ' && w !=
'.')
break;
1972 mem_set(dp->
fn,
' ', 11);
1973 for (si = 0; lfn[si] ==
' ' || lfn[si] ==
'.'; si++) ;
1975 while (di && lfn[di - 1] !=
'.') di--;
1981 if (w ==
' ' || (w ==
'.' && si != di)) {
1985 if (i >= ni || si == di) {
1991 si = di; i = 8; ni = 11;
1998 if (w) w = ExCvt[w - 0x80];
2005 if (_DF1S && w >= 0x100) {
2009 dp->
fn[i++] = (
BYTE)(w >> 8);
2011 if (!w || chk_chr(
"+,;=[]", w)) {
2028 if (ni == 8) b <<= 2;
2029 if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03)
2032 if ((b & 0x03) == 0x01) cf |=
NS_EXT;
2033 if ((b & 0x0C) == 0x04) cf |=
NS_BODY;
2047 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
2049 mem_set(sfn,
' ', 11);
2050 si = i = b = 0; ni = 8;
2055 if (c !=
'.' || si >= 3)
break;
2066 if (c <=
' ' || c ==
'/' || c ==
'\\')
break;
2067 if (c ==
'.' || i >= ni) {
2075 c = ExCvt[c - 0x80];
2084 if (!
IsDBCS2(d) || i >= ni - 1)
2089 if (chk_chr(
"\"*+,:;<=>\?[]|\x7F", c))
2107 if (ni == 8) b <<= 2;
2108 if ((b & 0x03) == 0x01) c |=
NS_EXT;
2109 if ((b & 0x0C) == 0x04) c |=
NS_BODY;
2135 if (*path ==
'/' || *path ==
'\\') {
2141 if (*path ==
'/' || *path ==
'\\')
2146 if ((
UINT)*path <
' ') {
2147 res = dir_sdi(dp, 0);
2151 res = create_name(dp, &path);
2152 if (res !=
FR_OK)
break;
2159 if (!(ns &
NS_LAST))
continue;
2172 dp->
sclust = ld_clust(dp->
fs, dir);
2191 const TCHAR *tp, *tt;
2203 for (tt = *path; (
UINT)*tt >= (
_USE_LFN ?
' ' :
'!') && *tt !=
':'; tt++) ;
2207 if (i < 10 && tp == tt) {
2217 sp = str[i]; tp = *path;
2219 c = *sp++; tc = *tp++;
2221 }
while (c && (
TCHAR)c == tc);
2222 }
while ((c || tp != tt) && ++i <
_VOLUMES);
2231 #if _FS_RPATH && _VOLUMES >= 2 2254 if (move_window(fs, sect) !=
FR_OK)
2285 DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4];
2293 vol = get_ldnumber(path);
2322 #if _MAX_SS != _MIN_SS 2328 fmt = check_fs(fs, bsect);
2329 if (fmt == 1 || (!fmt && (
LD2PT(vol)))) {
2330 for (i = 0; i < 4; i++) {
2332 br[i] = pt[4] ?
LD_DWORD(&pt[8]) : 0;
2338 fmt = bsect ? check_fs(fs, bsect) : 2;
2339 }
while (!
LD2PT(vol) && fmt && ++i < 4);
2375 nclst = (tsect - sysect) / fs->
csize;
2396 if (fs->
fsize < (szbfat + (
SS(fs) - 1)) /
SS(fs))
2405 #if (_FS_NOFSINFO & 3) != 3 2408 && move_window(fs, bsect + 1) ==
FR_OK)
2415 #if (_FS_NOFSINFO & 1) == 0 2418 #if (_FS_NOFSINFO & 2) == 0 2484 const TCHAR *rp = path;
2487 vol = get_ldnumber(&rp);
2496 if (!ff_del_syncobj(cfs->sobj))
return FR_INT_ERR;
2509 if (!fs || opt != 1)
return FR_OK;
2511 res = find_volume(&fs, &path, 0);
2546 res = find_volume(&dj.
fs, &path, 0);
2550 res = follow_path(&dj, path);
2558 res = chk_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
2568 res = dir_register(&dj);
2586 cl = ld_clust(dj.
fs, dir);
2591 res = remove_chain(dj.
fs, cl);
2594 res = move_window(dj.
fs, dw);
2615 fp->lockid = inc_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
2666 DWORD clst, sect, remain;
2680 if (btr > remain) btr = (
UINT)remain;
2683 rbuff += rcnt, fp->
fptr += rcnt, *br += rcnt, btr -= rcnt) {
2684 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2687 if (fp->
fptr == 0) {
2692 clst = clmt_clust(fp, fp->
fptr);
2704 cc = btr /
SS(fp->
fs);
2706 if (csect + cc > fp->
fs->
csize)
2710 #if !_FS_READONLY && _FS_MINIMIZE <= 2 2719 rcnt =
SS(fp->
fs) * cc;
2723 if (fp->
dsect != sect) {
2738 if (rcnt > btr) rcnt = btr;
2769 const BYTE *wbuff = (
const BYTE*)buff;
2781 if (fp->
fptr + btw < fp->fptr) btw = 0;
2784 wbuff += wcnt, fp->
fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2785 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2788 if (fp->
fptr == 0) {
2791 clst = create_chain(fp->
fs, 0);
2795 clst = clmt_clust(fp, fp->
fptr);
2798 clst = create_chain(fp->
fs, fp->
clust);
2800 if (clst == 0)
break;
2819 cc = btw /
SS(fp->
fs);
2821 if (csect + cc > fp->
fs->
csize)
2825 #if _FS_MINIMIZE <= 2 2832 if (fp->
dsect - sect < cc) {
2838 wcnt =
SS(fp->
fs) * cc;
2847 if (fp->
dsect != sect) {
2856 if (wcnt > btw) wcnt = btw;
2907 st_clust(dir, fp->
sclust);
2913 res = sync_fs(fp->
fs);
2948 res = dec_lock(fp->lockid);
2953 unlock_fs(fs,
FR_OK);
2976 vol = get_ldnumber(&path);
2979 CurrVol = (
BYTE)vol;
2996 res = find_volume(&dj.
fs, &path, 0);
2999 res = follow_path(&dj, path);
3006 dj.
fs->cdir = ld_clust(dj.
fs, dj.
dir);
3035 res = find_volume(&dj.
fs, (
const TCHAR**)&buff, 0);
3040 while ((ccl = dj.
sclust) != 0) {
3041 res = dir_sdi(&dj, 1);
3042 if (res !=
FR_OK)
break;
3043 res = dir_read(&dj, 0);
3044 if (res !=
FR_OK)
break;
3046 res = dir_sdi(&dj, 0);
3047 if (res !=
FR_OK)
break;
3049 res = dir_read(&dj, 0);
3050 if (res !=
FR_OK)
break;
3051 if (ccl == ld_clust(dj.
fs, dj.
dir))
break;
3052 res = dir_next(&dj, 0);
3053 }
while (res ==
FR_OK);
3055 if (res !=
FR_OK)
break;
3060 get_fileinfo(&dj, &fno);
3063 if (*buff) tp = buff;
3065 for (n = 0; tp[n]; n++) ;
3069 while (n) buff[--i] = tp[--n];
3075 *tp++ =
'0' + CurrVol;
3097 #if _FS_MINIMIZE <= 2 3108 DWORD clst, bcs, nsect, ifptr;
3110 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
3123 tlen = *tbl++; ulen = 2;
3128 tcl = cl; ncl = 0; ulen += 2;
3134 }
while (cl == pcl + 1);
3136 *tbl++ = ncl; *tbl++ = tcl;
3147 if (ofs > fp->
fsize)
3151 fp->
clust = clmt_clust(fp, ofs - 1);
3154 dsc += (ofs - 1) /
SS(fp->
fs) & (fp->
fs->
csize - 1);
3183 fp->
fptr = nsect = 0;
3187 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
3188 fp->
fptr = (ifptr - 1) & ~(bcs - 1);
3195 clst = create_chain(fp->
fs, 0);
3207 clst = create_chain(fp->
fs, clst);
3221 if (ofs %
SS(fp->
fs)) {
3224 nsect += ofs /
SS(fp->
fs);
3255 #if _FS_MINIMIZE <= 1 3273 res = find_volume(&fs, &path, 0);
3277 res = follow_path(dp, path);
3288 res = dir_sdi(dp, 0);
3292 dp->lockid = inc_lock(dp, 0);
3330 res = dec_lock(dp->lockid);
3335 unlock_fs(fs,
FR_OK);
3360 res = dir_sdi(dp, 0);
3363 res = dir_read(dp, 0);
3369 get_fileinfo(dp, fno);
3370 res = dir_next(dp, 0);
3400 if (res !=
FR_OK || !fno || !fno->
fname[0])
break;
3402 if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0))
break;
3404 if (pattern_matching(dp->pat, fno->
fname, 0, 0))
break;
3420 const TCHAR* pattern
3437 #if _FS_MINIMIZE == 0 3453 res = find_volume(&dj.
fs, &path, 0);
3456 res = follow_path(&dj, path);
3459 if (fno) get_fileinfo(&dj, fno);
3485 DWORD n, clst, sect, stat;
3491 res = find_volume(fatfs, &path, 0);
3505 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
3508 }
while (++clst < fs->n_fatent);
3515 res = move_window(fs, sect++);
3516 if (res !=
FR_OK)
break;
3524 if ((
LD_DWORD(p) & 0x0FFFFFFF) == 0) n++;
3565 if (fp->
fptr == 0) {
3566 res = remove_chain(fp->
fs, fp->
sclust);
3575 if (res ==
FR_OK) res = remove_chain(fp->
fs, ncl);
3612 res = find_volume(&dj.
fs, &path, 1);
3615 res = follow_path(&dj, path);
3619 if (res ==
FR_OK) res = chk_lock(&dj, 2);
3630 dclst = ld_clust(dj.
fs, dir);
3633 if (dclst == dj.
fs->cdir) {
3638 mem_cpy(&sdj, &dj,
sizeof (
DIR));
3640 res = dir_sdi(&sdj, 2);
3642 res = dir_read(&sdj, 0);
3650 res = dir_remove(&dj);
3651 if (res ==
FR_OK && dclst)
3652 res = remove_chain(dj.
fs, dclst);
3653 if (res ==
FR_OK) res = sync_fs(dj.
fs);
3681 res = find_volume(&dj.
fs, &path, 1);
3684 res = follow_path(&dj, path);
3689 dcl = create_chain(dj.
fs, 0);
3695 res = sync_window(dj.
fs);
3699 mem_set(dir, 0,
SS(dj.
fs));
3710 for (n = dj.
fs->
csize; n; n--) {
3713 res = sync_window(dj.
fs);
3714 if (res !=
FR_OK)
break;
3715 mem_set(dir, 0,
SS(dj.
fs));
3718 if (res ==
FR_OK) res = dir_register(&dj);
3720 remove_chain(dj.
fs, dcl);
3727 res = sync_fs(dj.
fs);
3756 res = find_volume(&dj.
fs, &path, 1);
3759 res = follow_path(&dj, path);
3771 res = sync_fs(dj.
fs);
3787 const TCHAR* path_old,
3788 const TCHAR* path_new
3799 res = find_volume(&djo.
fs, &path_old, 1);
3803 res = follow_path(&djo, path_old);
3807 if (res ==
FR_OK) res = chk_lock(&djo, 2);
3814 mem_cpy(&djn, &djo,
sizeof (
DIR));
3815 if (get_ldnumber(&path_new) >= 0)
3816 res = follow_path(&djn, path_new);
3821 res = dir_register(&djn);
3825 mem_cpy(dir + 13, buf + 2, 19);
3833 res = move_window(djo.
fs, dw);
3835 if (res ==
FR_OK && dir[1] ==
'.') {
3836 st_clust(dir, djn.
sclust);
3842 res = dir_remove(&djo);
3844 res = sync_fs(djo.
fs);
3876 res = find_volume(&dj.
fs, &path, 1);
3879 res = follow_path(&dj, path);
3891 res = sync_fs(dj.
fs);
3921 #if _USE_LFN && _LFN_UNICODE 3927 res = find_volume(&dj.
fs, &path, 0);
3930 if (res ==
FR_OK && label) {
3932 res = dir_sdi(&dj, 0);
3934 res = dir_read(&dj, 1);
3936 #if _USE_LFN && _LFN_UNICODE 3939 w = (i < 11) ? dj.
dir[i++] :
' ';
3941 w = w << 8 | dj.
dir[i++];
3945 mem_cpy(label, dj.
dir, 11);
3951 }
while (label[--j] ==
' ');
3961 if (res ==
FR_OK && vsn) {
3992 res = find_volume(&dj.
fs, &label, 1);
3997 for (sl = 0; label[sl]; sl++) ;
3998 for ( ; sl && label[sl - 1] ==
' '; sl--) ;
4002 #if _USE_LFN && _LFN_UNICODE 4005 w = (
BYTE)label[i++];
4007 w = (j < 10 && i < sl &&
IsDBCS2(label[i])) ? w << 8 | (
BYTE)label[i++] : 0;
4013 if (w >= 0x80) w = ExCvt[w - 0x80];
4015 if (!_DF1S && w >= 0x80) w = 0;
4019 if (!w || chk_chr(
"\"*+,.:;<=>\?[]|\x7F", w) || j >= (
UINT)((w >= 0x100) ? 10 : 11))
4021 if (w >= 0x100) vn[j++] = (
BYTE)(w >> 8);
4024 while (j < 11) vn[j++] =
' ';
4030 res = dir_sdi(&dj, 0);
4032 res = dir_read(&dj, 1);
4035 mem_cpy(dj.
dir, vn, 11);
4042 res = sync_fs(dj.
fs);
4047 res = dir_alloc(&dj, 1);
4050 mem_cpy(dj.
dir, vn, 11);
4055 res = sync_fs(dj.
fs);
4073 #if _USE_FORWARD && _FS_TINY 4083 DWORD remain, clst, sect;
4098 if (btf > remain) btf = (
UINT)remain;
4100 for ( ; btf && (*func)(0, 0);
4101 fp->
fptr += rcnt, *bf += rcnt, btf -= rcnt) {
4103 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
4105 clst = (fp->
fptr == 0) ?
4115 if (move_window(fp->
fs, sect) !=
FR_OK)
4119 if (rcnt > btf) rcnt = btf;
4130 #if _USE_MKFS && !_FS_READONLY 4134 #define N_ROOTDIR 512 4144 static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0};
4145 static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512};
4147 BYTE fmt, md, sys, *tbl, pdrv, part;
4148 DWORD n_clst, vs, n, wsect;
4150 DWORD b_vol, b_fat, b_dir, b_data;
4151 DWORD n_vol, n_rsv, n_fat, n_dir;
4161 vol = get_ldnumber(&path);
4173 #if _MAX_SS != _MIN_SS 4189 b_vol = (sfd) ? 0 : 63;
4193 if (au & (au - 1)) au = 0;
4195 vs = n_vol / (2000 / (
SS(fs) / 512));
4196 for (i = 0; vs < vst[i]; i++) ;
4201 if (au > 128) au = 128;
4204 n_clst = n_vol / au;
4211 n_fat = ((n_clst * 4) + 8 +
SS(fs) - 1) /
SS(fs);
4215 n_fat = (fmt ==
FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4;
4216 n_fat = (n_fat +
SS(fs) - 1) /
SS(fs);
4220 b_fat = b_vol + n_rsv;
4221 b_dir = b_fat + n_fat * N_FATS;
4222 b_data = b_dir + n_dir;
4227 n = (b_data + n - 1) & ~(n - 1);
4228 n = (n - b_data) / N_FATS;
4237 n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au;
4246 if (fmt ==
FS_FAT12 && n_vol < 0x10000) {
4249 sys = (n_vol < 0x10000) ? 0x04 : 0x06;
4264 mem_set(fs->
win.
d8, 0,
SS(fs));
4271 n = (b_vol + n_vol) / 63 / 255;
4272 tbl[6] = (
BYTE)(n >> 2 | 63);
4285 mem_set(tbl, 0,
SS(fs));
4286 mem_cpy(tbl,
"\xEB\xFE\x90" "MSDOS5.0", 11);
4292 i = (fmt ==
FS_FAT32) ? 0 : N_ROOTDIR;
4294 if (n_vol < 0x10000) {
4312 mem_cpy(tbl +
BS_VolLab32,
"NO NAME " "FAT32 ", 19);
4318 mem_cpy(tbl +
BS_VolLab,
"NO NAME " "FAT ", 19);
4328 for (i = 0; i < N_FATS; i++) {
4329 mem_set(tbl, 0,
SS(fs));
4332 n |= (fmt ==
FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00;
4342 mem_set(tbl, 0,
SS(fs));
4343 for (n = 1; n < n_fat; n++) {
4358 eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt ==
FS_FAT32) ? 1 : 0)) * au - 1;
4379 #if _MULTI_PARTITION 4390 UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
4391 BYTE s_hd, e_hd, *p, *buf = (
BYTE*)work;
4393 DWORD sz_disk, sz_part, s_part;
4402 for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ;
4406 tot_cyl = sz_disk / sz_cyl;
4411 for (i = 0; i < 4; i++, p +=
SZ_PTE) {
4412 p_cyl = (szt[i] <= 100U) ? (
DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl;
4413 if (!p_cyl)
continue;
4414 s_part = (
DWORD)sz_cyl * b_cyl;
4415 sz_part = (
DWORD)sz_cyl * p_cyl;
4418 s_part += 63; sz_part -= 63;
4422 e_cyl = b_cyl + p_cyl - 1;
4427 p[2] = (
BYTE)((b_cyl >> 2) + 1);
4431 p[6] = (
BYTE)((e_cyl >> 2) + 63);
4469 while (n < len - 1) {
4470 #if _USE_LFN && _LFN_UNICODE 4471 #if _STRF_ENCODE == 3 4476 if (c < 0xC0)
continue;
4480 c = (c & 0x1F) << 6 | (s[0] & 0x3F);
4481 if (c < 0x80) c =
'?';
4486 c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F);
4487 if (c < 0x800) c =
'?';
4493 #elif _STRF_ENCODE == 2 4496 c = s[1] + (s[0] << 8);
4497 #elif _STRF_ENCODE == 1 4500 c = s[0] + (s[1] << 8);
4508 c = (c << 8) + s[0];
4521 if (c ==
'\n')
break;
4524 return n ? buff : 0;
4559 #if _USE_LFN && _LFN_UNICODE 4560 #if _STRF_ENCODE == 3 4562 pb->buf[i++] = (
BYTE)c;
4565 pb->buf[i++] = (
BYTE)(0xC0 | c >> 6);
4567 pb->buf[i++] = (
BYTE)(0xE0 | c >> 12);
4568 pb->buf[i++] = (
BYTE)(0x80 | (c >> 6 & 0x3F));
4570 pb->buf[i++] = (
BYTE)(0x80 | (c & 0x3F));
4572 #elif _STRF_ENCODE == 2 4573 pb->buf[i++] = (
BYTE)(c >> 8);
4574 pb->buf[i++] = (
BYTE)c;
4575 #elif _STRF_ENCODE == 1 4576 pb->buf[i++] = (
BYTE)c;
4577 pb->buf[i++] = (
BYTE)(c >> 8);
4582 pb->buf[i++] = (
BYTE)(c >> 8);
4583 pb->buf[i++] = (
BYTE)c;
4586 pb->buf[i++] = (
BYTE)c;
4589 if (i >= (
int)(
sizeof pb->buf) - 3) {
4591 i = (bw == (
UINT)i) ? 0 : -1;
4609 pb.nchr = pb.idx = 0;
4615 && (
UINT)pb.idx == nw)
return pb.nchr;
4636 pb.nchr = pb.idx = 0;
4639 putc_bfd(&pb, *str++);
4643 && (
UINT)pb.idx == nw)
return pb.nchr;
4664 TCHAR c, d, s[16], *p;
4669 pb.nchr = pb.idx = 0;
4690 w = w * 10 + c -
'0';
4693 if (c ==
'l' || c ==
'L') {
4701 p = va_arg(arp,
TCHAR*);
4702 for (j = 0; p[j]; j++) ;
4704 while (j++ < w) putc_bfd(&pb,
' ');
4706 while (*p) putc_bfd(&pb, *p++);
4707 while (j++ < w) putc_bfd(&pb,
' ');
4710 putc_bfd(&pb, (
TCHAR)va_arg(arp,
int));
continue;
4721 putc_bfd(&pb, c);
continue;
4725 v = (f & 4) ? (
DWORD)va_arg(arp,
long) : ((d ==
'D') ? (
DWORD)(long)va_arg(arp,
int) : (
DWORD)va_arg(arp,
unsigned int));
4726 if (d ==
'D' && (v & 0x80000000)) {
4732 d = (
TCHAR)(v % r); v /= r;
4733 if (d > 9) d += (c ==
'x') ? 0x27 : 0x07;
4735 }
while (v && i <
sizeof s /
sizeof s[0]);
4736 if (f & 8) s[i++] =
'-';
4737 j = i; d = (f & 1) ?
'0' :
' ';
4738 while (!(f & 2) && j++ < w) putc_bfd(&pb, d);
4739 do putc_bfd(&pb, s[--i]);
while (i);
4740 while (j++ < w) putc_bfd(&pb, d);
4747 && (
UINT)pb.idx == nw)
return pb.nchr;
FRESULT f_chdrive(const TCHAR *path)
int f_puts(const TCHAR *str, FIL *cp)
WCHAR ff_wtoupper(WCHAR chr)
int f_putc(TCHAR c, FIL *fp)
FRESULT f_closedir(DIR *dp)
FRESULT f_unlink(const TCHAR *path)
FRESULT f_fdisk(BYTE pdrv, const DWORD szt[], void *work)
FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *vsn)
#define ST_DWORD(ptr, val)
#define LEAVE_FF(fs, res)
DWORD clust2sect(FATFS *fs, DWORD clst)
FRESULT f_chdir(const TCHAR *path)
FRESULT f_chmod(const TCHAR *path, BYTE attr, BYTE mask)
WCHAR ff_convert(WCHAR chr, UINT dir)
FRESULT f_truncate(FIL *fp)
FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Writes Sector(s)
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *, UINT), UINT btf, UINT *bf)
DSTATUS disk_status(BYTE pdrv)
Gets Disk Status.
FRESULT f_readdir(DIR *dp, FILINFO *fno)
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
I/O control operation.
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
FRESULT f_lseek(FIL *fp, DWORD ofs)
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
#define ST_WORD(ptr, val)
DWORD get_fat(FATFS *fs, DWORD clst)
FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
FRESULT f_mkfs(const TCHAR *path, BYTE sfd, UINT au)
DSTATUS disk_initialize(BYTE pdrv)
Initializes a Drive.
FRESULT f_opendir(DIR *dp, const TCHAR *path)
FRESULT f_setlabel(const TCHAR *label)
FRESULT f_findfirst(DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern)
FRESULT f_mkdir(const TCHAR *path)
TCHAR * f_gets(TCHAR *buff, int len, FIL *fp)
int f_printf(FIL *fp, const TCHAR *str,...)
FRESULT f_findnext(DIR *dp, FILINFO *fno)
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
FRESULT f_getcwd(TCHAR *buff, UINT len)
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Reads Sector(s)
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)