33 #if FF_DEFINED != 63463 34 #error Wrong include file (ff.h). 39 #define IsUpper(c) ((c) >= 'A' && (c) <= 'Z') 40 #define IsLower(c) ((c) >= 'a' && (c) <= 'z') 41 #define IsDigit(c) ((c) >= '0' && (c) <= '9') 42 #define IsSurrogate(c) ((c) >= 0xD800 && (c) <= 0xDFFF) 43 #define IsSurrogateH(c) ((c) >= 0xD800 && (c) <= 0xDBFF) 44 #define IsSurrogateL(c) ((c) >= 0xDC00 && (c) <= 0xDFFF) 54 #define FA_SEEKEND 0x20 55 #define FA_MODIFIED 0x40 68 #define NS_NONAME 0x80 72 #define MAX_DIR 0x200000 73 #define MAX_DIR_EX 0x10000000 74 #define MAX_FAT12 0xFF5 75 #define MAX_FAT16 0xFFF5 76 #define MAX_FAT32 0x0FFFFFF5 77 #define MAX_EXFAT 0x7FFFFFFD 85 #define BPB_BytsPerSec 11 86 #define BPB_SecPerClus 13 87 #define BPB_RsvdSecCnt 14 88 #define BPB_NumFATs 16 89 #define BPB_RootEntCnt 17 90 #define BPB_TotSec16 19 92 #define BPB_FATSz16 22 93 #define BPB_SecPerTrk 24 94 #define BPB_NumHeads 26 95 #define BPB_HiddSec 28 96 #define BPB_TotSec32 32 102 #define BS_FilSysType 54 103 #define BS_BootCode 62 106 #define BPB_FATSz32 36 107 #define BPB_ExtFlags32 40 108 #define BPB_FSVer32 42 109 #define BPB_RootClus32 44 110 #define BPB_FSInfo32 48 111 #define BPB_BkBootSec32 50 112 #define BS_DrvNum32 64 113 #define BS_NTres32 65 114 #define BS_BootSig32 66 115 #define BS_VolID32 67 116 #define BS_VolLab32 71 117 #define BS_FilSysType32 82 118 #define BS_BootCode32 90 120 #define BPB_ZeroedEx 11 121 #define BPB_VolOfsEx 64 122 #define BPB_TotSecEx 72 123 #define BPB_FatOfsEx 80 124 #define BPB_FatSzEx 84 125 #define BPB_DataOfsEx 88 126 #define BPB_NumClusEx 92 127 #define BPB_RootClusEx 96 128 #define BPB_VolIDEx 100 129 #define BPB_FSVerEx 104 130 #define BPB_VolFlagEx 106 131 #define BPB_BytsPerSecEx 108 132 #define BPB_SecPerClusEx 109 133 #define BPB_NumFATsEx 110 134 #define BPB_DrvNumEx 111 135 #define BPB_PercInUseEx 112 136 #define BPB_RsvdEx 113 137 #define BS_BootCodeEx 120 142 #define DIR_CrtTime10 13 143 #define DIR_CrtTime 14 144 #define DIR_LstAccDate 18 145 #define DIR_FstClusHI 20 146 #define DIR_ModTime 22 147 #define DIR_FstClusLO 26 148 #define DIR_FileSize 28 152 #define LDIR_Chksum 13 153 #define LDIR_FstClusLO 26 155 #define XDIR_NumLabel 1 157 #define XDIR_CaseSum 4 158 #define XDIR_NumSec 1 159 #define XDIR_SetSum 2 161 #define XDIR_CrtTime 8 162 #define XDIR_ModTime 12 163 #define XDIR_AccTime 16 164 #define XDIR_CrtTime10 20 165 #define XDIR_ModTime10 21 166 #define XDIR_CrtTZ 22 167 #define XDIR_ModTZ 23 168 #define XDIR_AccTZ 24 169 #define XDIR_GenFlags 33 170 #define XDIR_NumName 35 171 #define XDIR_NameHash 36 172 #define XDIR_ValidFileSize 40 173 #define XDIR_FstClus 52 174 #define XDIR_FileSize 56 181 #define FSI_LeadSig 0 182 #define FSI_StrucSig 484 183 #define FSI_Free_Count 488 184 #define FSI_Nxt_Free 492 186 #define MBR_Table 446 197 #define PTE_SizLba 12 201 #define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } 207 #error Static LFN work area cannot be used at thread-safe configuration 209 #define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } 211 #define LEAVE_FF(fs, res) return res 216 #if FF_MULTI_PARTITION 217 #define LD2PD(vol) VolToPart[vol].pd 218 #define LD2PT(vol) VolToPart[vol].pt 220 #define LD2PD(vol) (BYTE)(vol) 226 #if (FF_MAX_SS < FF_MIN_SS) || (FF_MAX_SS != 512 && FF_MAX_SS != 1024 && FF_MAX_SS != 2048 && FF_MAX_SS != 4096) || (FF_MIN_SS != 512 && FF_MIN_SS != 1024 && FF_MIN_SS != 2048 && FF_MIN_SS != 4096) 227 #error Wrong sector size configuration 229 #if FF_MAX_SS == FF_MIN_SS 230 #define SS(fs) ((UINT)FF_MAX_SS) 232 #define SS(fs) ((fs)->ssize) 237 #if 0 // FF_FS_NORTC == 1 238 #if FF_NORTC_YEAR < 1980 || FF_NORTC_YEAR > 2107 || FF_NORTC_MON < 1 || FF_NORTC_MON > 12 || FF_NORTC_MDAY < 1 || FF_NORTC_MDAY > 31 239 #error Invalid FF_FS_NORTC settings 241 #define GET_FATTIME() ((DWORD)(FF_NORTC_YEAR - 1980) << 25 | (DWORD)FF_NORTC_MON << 21 | (DWORD)FF_NORTC_MDAY << 16) 243 #define GET_FATTIME() get_fattime() 250 #error FF_FS_LOCK must be 0 at read-only configuration 262 #define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ 263 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 264 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ 265 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 266 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 267 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 268 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ 269 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,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E5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ 381 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 382 #define TBL_CT866 {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 383 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 384 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 385 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 386 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 387 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 388 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 389 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 390 #define TBL_CT869 {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 391 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ 392 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,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D2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} 412 #define TBL_DC932 {0x81, 0x9F, 0xE0, 0xFC, 0x40, 0x7E, 0x80, 0xFC, 0x00, 0x00} 413 #define TBL_DC936 {0x81, 0xFE, 0x00, 0x00, 0x40, 0x7E, 0x80, 0xFE, 0x00, 0x00} 414 #define TBL_DC949 {0x81, 0xFE, 0x00, 0x00, 0x41, 0x5A, 0x61, 0x7A, 0x81, 0xFE} 415 #define TBL_DC950 {0x81, 0xFE, 0x00, 0x00, 0x40, 0x7E, 0xA1, 0xFE, 0x00, 0x00} 419 #define MERGE_2STR(a, b) a ## b 420 #define MKCVTBL(hd, cp) MERGE_2STR(hd, cp) 438 #if FF_VOLUMES < 1 || FF_VOLUMES > 10 439 #error Wrong FF_VOLUMES setting 453 #ifdef FF_VOLUME_STRS 465 #error LFN must be enabled when enable exFAT 468 #define INIT_NAMBUF(fs) 469 #define FREE_NAMBUF() 470 #define LEAVE_MKFS(res) return res 473 #if FF_MAX_LFN < 12 || FF_MAX_LFN > 255 474 #error Wrong setting of FF_MAX_LFN 476 #if FF_LFN_BUF < FF_SFN_BUF || FF_SFN_BUF < 12 477 #error Wrong setting of FF_LFN_BUF or FF_SFN_BUF 479 #if FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3 480 #error Wrong setting of FF_LFN_UNICODE 482 static const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
483 #define MAXDIRB(nc) ((nc + 44U) / 15 * SZDIRE) 491 #define INIT_NAMBUF(fs) 492 #define FREE_NAMBUF() 493 #define LEAVE_MKFS(res) return res 495 #elif FF_USE_LFN == 2 497 #define DEF_NAMBUF WCHAR lbuf[FF_MAX_LFN+1]; BYTE dbuf[MAXDIRB(FF_MAX_LFN)]; 498 #define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; (fs)->dirbuf = dbuf; } 499 #define FREE_NAMBUF() 501 #define DEF_NAMBUF WCHAR lbuf[FF_MAX_LFN+1]; 502 #define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; } 503 #define FREE_NAMBUF() 505 #define LEAVE_MKFS(res) return res 507 #elif FF_USE_LFN == 3 509 #define DEF_NAMBUF WCHAR *lfn; 510 #define INIT_NAMBUF(fs) { lfn = ff_memalloc((FF_MAX_LFN+1)*2 + MAXDIRB(FF_MAX_LFN)); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; (fs)->dirbuf = (BYTE*)(lfn+FF_MAX_LFN+1); } 511 #define FREE_NAMBUF() ff_memfree(lfn) 513 #define DEF_NAMBUF WCHAR *lfn; 514 #define INIT_NAMBUF(fs) { lfn = ff_memalloc((FF_MAX_LFN+1)*2); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; } 515 #define FREE_NAMBUF() ff_memfree(lfn) 517 #define LEAVE_MKFS(res) { if (!work) ff_memfree(buf); return res; } 518 #define MAX_MALLOC 0x8000 521 #error Wrong setting of FF_USE_LFN 532 #if FF_CODE_PAGE == 0 533 #define CODEPAGE CodePage 534 static WORD CodePage;
558 #elif FF_CODE_PAGE < 900 || FF_CODE_PAGE > 1000 559 #define CODEPAGE FF_CODE_PAGE 563 #define CODEPAGE FF_CODE_PAGE 585 static void gen_numname (
BYTE* dst,
const BYTE* src,
const WCHAR* lfn,
UINT seq);
597 rv = rv << 8 | ptr[0];
606 rv = rv << 8 | ptr[2];
607 rv = rv << 8 | ptr[1];
608 rv = rv << 8 | ptr[0];
618 rv = rv << 8 | ptr[6];
619 rv = rv << 8 | ptr[5];
620 rv = rv << 8 | ptr[4];
621 rv = rv << 8 | ptr[3];
622 rv = rv << 8 | ptr[2];
623 rv = rv << 8 | ptr[1];
624 rv = rv << 8 | ptr[0];
632 *ptr++ = (
BYTE)val; val >>= 8;
638 *ptr++ = (
BYTE)val; val >>= 8;
639 *ptr++ = (
BYTE)val; val >>= 8;
640 *ptr++ = (
BYTE)val; val >>= 8;
645 static void st_qword (
BYTE* ptr,
QWORD val)
647 *ptr++ = (
BYTE)val; val >>= 8;
648 *ptr++ = (
BYTE)val; val >>= 8;
649 *ptr++ = (
BYTE)val; val >>= 8;
650 *ptr++ = (
BYTE)val; val >>= 8;
651 *ptr++ = (
BYTE)val; val >>= 8;
652 *ptr++ = (
BYTE)val; val >>= 8;
653 *ptr++ = (
BYTE)val; val >>= 8;
683 return memcmp(dst,src, cnt);
690 while (*str && *str != chr) str++;
698 #if FF_CODE_PAGE == 0 699 if (DbcTbl && c >= DbcTbl[0]) {
700 if (c <= DbcTbl[1])
return 1;
701 if (c >= DbcTbl[2] && c <= DbcTbl[3])
return 1;
703 #elif FF_CODE_PAGE >= 900 && FF_CODE_PAGE < 1000 704 if (c >= DbcTbl[0]) {
705 if (c <= DbcTbl[1])
return 1;
706 if (c >= DbcTbl[2] && c <= DbcTbl[3])
return 1;
709 if (c != 0)
return 0;
718 #if FF_CODE_PAGE == 0 719 if (DbcTbl && c >= DbcTbl[4]) {
720 if (c <= DbcTbl[5])
return 1;
721 if (c >= DbcTbl[6] && c <= DbcTbl[7])
return 1;
722 if (c >= DbcTbl[8] && c <= DbcTbl[9])
return 1;
724 #elif FF_CODE_PAGE >= 900 && FF_CODE_PAGE < 1000 725 if (c >= DbcTbl[4]) {
726 if (c <= DbcTbl[5])
return 1;
727 if (c >= DbcTbl[6] && c <= DbcTbl[7])
return 1;
728 if (c >= DbcTbl[8] && c <= DbcTbl[9])
return 1;
731 if (c != 0)
return 0;
740 static DWORD tchar2uni (
745 const TCHAR *p = *str;
747 #if FF_LFN_UNICODE == 1 757 #elif FF_LFN_UNICODE == 2 763 if ((uc & 0xE0) == 0xC0) {
766 if ((uc & 0xF0) == 0xE0) {
769 if ((uc & 0xF8) == 0xF0) {
778 if ((b & 0xC0) != 0x80)
return 0xFFFFFFFF;
779 uc = uc << 6 | (b & 0x3F);
781 if (uc < 0x80 ||
IsSurrogate(uc) || uc >= 0x110000)
return 0xFFFFFFFF;
782 if (uc >= 0x010000) uc = 0xD800DC00 | ((uc - 0x10000) << 6 & 0x3FF0000) | (uc & 0x3FF);
785 #elif FF_LFN_UNICODE == 3 787 if (uc >= 0x110000)
return 0xFFFFFFFF;
788 if (uc >= 0x010000) uc = 0xD800DC00 | ((uc - 0x10000) << 6 & 0x3FF0000) | (uc & 0x3FF);
797 if (!
dbc_2nd(b))
return 0xFFFFFFFF;
802 if (wc == 0)
return 0xFFFFFFFF;
813 static BYTE put_utf (
819 #if FF_LFN_UNICODE == 1 822 hs = (
WCHAR)(chr >> 16);
834 #elif FF_LFN_UNICODE == 2 838 if (szb < 1)
return 0;
843 if (szb < 2)
return 0;
844 *buf++ = (
TCHAR)(0xC0 | (chr >> 6 & 0x1F));
845 *buf++ = (
TCHAR)(0x80 | (chr >> 0 & 0x3F));
850 *buf++ = (
TCHAR)(0xE0 | (chr >> 12 & 0x0F));
851 *buf++ = (
TCHAR)(0x80 | (chr >> 6 & 0x3F));
852 *buf++ = (
TCHAR)(0x80 | (chr >> 0 & 0x3F));
856 if (szb < 4)
return 0;
857 hc = ((chr & 0xFFFF0000) - 0xD8000000) >> 6;
858 chr = (chr & 0xFFFF) - 0xDC00;
859 if (hc >= 0x100000 || chr >= 0x400)
return 0;
860 chr = (hc | chr) + 0x10000;
861 *buf++ = (
TCHAR)(0xF0 | (chr >> 18 & 0x07));
862 *buf++ = (
TCHAR)(0x80 | (chr >> 12 & 0x3F));
863 *buf++ = (
TCHAR)(0x80 | (chr >> 6 & 0x3F));
864 *buf++ = (
TCHAR)(0x80 | (chr >> 0 & 0x3F));
867 #elif FF_LFN_UNICODE == 3 870 if (szb < 1)
return 0;
871 if (chr >= 0x10000) {
872 hc = ((chr & 0xFFFF0000) - 0xD8000000) >> 6;
873 chr = (chr & 0xFFFF) - 0xDC00;
874 if (hc >= 0x100000 || chr >= 0x400)
return 0;
875 chr = (hc | chr) + 0x10000;
885 if (szb < 2)
return 0;
886 *buf++ = (char)(wc >> 8);
890 if (wc == 0 || szb < 1)
return 0;
906 return ff_req_grant(fs->sobj);
910 static void unlock_fs (
916 ff_rel_grant(fs->sobj);
940 if (Files[i].fs == dp->
obj.
fs &&
942 Files[i].ofs == dp->
dptr)
break;
947 if (i == FF_FS_LOCK) {
956 static int enq_lock (
void)
960 for (i = 0; i <
FF_FS_LOCK && Files[i].fs; i++) ;
965 static UINT inc_lock (
974 if (Files[i].fs == dp->
obj.
fs &&
976 Files[i].ofs == dp->
dptr)
break;
979 if (i == FF_FS_LOCK) {
980 for (i = 0; i < FF_FS_LOCK && Files[i].fs; i++) ;
981 if (i == FF_FS_LOCK)
return 0;
982 Files[i].fs = dp->
obj.
fs;
984 Files[i].ofs = dp->
dptr;
988 if (acc >= 1 && Files[i].ctr)
return 0;
990 Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1;
1006 if (n == 0x100) n = 0;
1009 if (n == 0) Files[i].fs = 0;
1018 static void clear_lock (
1025 if (Files[i].fs == fs) Files[i].fs = 0;
1073 sector = 0xFFFFFFFF;
1133 if (clst >= fs->
n_fatent - 2)
return 0;
1154 if (clst < 2 || clst >= fs->
n_fatent) {
1162 bc = (
UINT)clst; bc += bc / 2;
1164 wc = fs->
win[bc++ %
SS(fs)];
1166 wc |= fs->
win[bc %
SS(fs)] << 8;
1167 val = (clst & 1) ? (wc >> 4) : (wc & 0xFFF);
1185 if (obj->
stat == 2 && cofs <= clen) {
1186 val = (cofs == clen) ? 0x7FFFFFFF : clst + 1;
1189 if (obj->
stat == 3 && cofs < obj->n_cont) {
1193 if (obj->
stat != 2) {
1194 if (obj->n_frag != 0) {
1232 if (clst >= 2 && clst < fs->n_fatent) {
1235 bc = (
UINT)clst; bc += bc / 2;
1237 if (res !=
FR_OK)
break;
1238 p = fs->
win + bc++ %
SS(fs);
1239 *p = (clst & 1) ? ((*p & 0x0F) | ((
BYTE)val << 4)) : (
BYTE)val;
1242 if (res !=
FR_OK)
break;
1243 p = fs->
win + bc %
SS(fs);
1244 *p = (clst & 1) ? (
BYTE)(val >> 4) : ((*p & 0xF0) | ((
BYTE)(val >> 8) & 0x0F));
1250 if (res !=
FR_OK)
break;
1260 if (res !=
FR_OK)
break;
1262 val = (val & 0x0FFFFFFF) | (
ld_dword(fs->
win + clst * 4 %
SS(fs)) & 0xF0000000);
1277 #if FF_FS_EXFAT && !FF_FS_READONLY 1286 static DWORD find_bitmap (
1294 DWORD val, scl, ctr;
1298 if (clst >= fs->
n_fatent - 2) clst = 0;
1299 scl = val = clst; ctr = 0;
1302 i = val / 8 %
SS(fs); bm = 1 << (val % 8);
1305 bv = fs->
win[i] & bm; bm <<= 1;
1307 val = 0; bm = 0; i =
SS(fs);
1310 if (++ctr == ncl)
return scl + 2;
1314 if (val == clst)
return 0;
1317 }
while (++i <
SS(fs));
1326 static FRESULT change_bitmap (
1340 i = clst / 8 %
SS(fs);
1341 bm = 1 << (clst % 8);
1349 if (--ncl == 0)
return FR_OK;
1352 }
while (++i <
SS(fs));
1362 static FRESULT fill_first_frag (
1370 if (obj->
stat == 3) {
1371 for (cl = obj->
sclust, n = obj->n_cont; n; cl++, n--) {
1373 if (res !=
FR_OK)
return res;
1385 static FRESULT fill_last_frag (
1394 while (obj->n_frag > 0) {
1395 res =
put_fat(obj->
fs, lcl - obj->n_frag + 1, (obj->n_frag > 1) ? lcl - obj->n_frag + 2 : term);
1396 if (res !=
FR_OK)
return res;
1420 #if FF_FS_EXFAT || FF_USE_TRIM 1421 DWORD scl = clst, ecl = clst;
1431 res =
put_fat(fs, pclst, 0xFFFFFFFF);
1432 if (res !=
FR_OK)
return res;
1438 if (nxt == 0)
break;
1443 if (res !=
FR_OK)
return res;
1449 #if FF_FS_EXFAT || FF_USE_TRIM 1450 if (ecl + 1 == nxt) {
1455 res = change_bitmap(fs, scl, ecl - scl + 1, 0);
1456 if (res !=
FR_OK)
return res;
1468 }
while (clst < fs->n_fatent);
1476 if (obj->
stat == 0) {
1478 while (clst != pclst) {
1482 if (nxt != clst + 1)
break;
1485 if (clst == pclst) {
1489 if (obj->
stat == 3 && pclst >= obj->
sclust && pclst <= obj->sclust + obj->n_cont) {
1518 if (scl == 0 || scl >= fs->
n_fatent) scl = 1;
1522 if (cs < 2)
return 1;
1523 if (cs == 0xFFFFFFFF)
return cs;
1524 if (cs < fs->n_fatent)
return cs;
1531 ncl = find_bitmap(fs, scl, 1);
1532 if (ncl == 0 || ncl == 0xFFFFFFFF)
return ncl;
1533 res = change_bitmap(fs, ncl, 1, 1);
1539 if (obj->
stat == 2 && ncl != scl + 1) {
1540 obj->n_cont = scl - obj->
sclust;
1544 if (obj->
stat != 2) {
1545 if (ncl == clst + 1) {
1546 obj->n_frag = obj->n_frag ? obj->n_frag + 1 : 2;
1548 if (obj->n_frag == 0) obj->n_frag = 1;
1549 res = fill_last_frag(obj, clst, ncl);
1550 if (res ==
FR_OK) obj->n_frag = 1;
1561 if (cs == 1 || cs == 0xFFFFFFFF)
return cs;
1564 if (cs >= 2 && cs < fs->n_fatent) scl = cs;
1574 if (ncl > scl)
return 0;
1578 if (cs == 1 || cs == 0xFFFFFFFF)
return cs;
1579 if (ncl == scl)
return 0;
1582 res =
put_fat(fs, ncl, 0xFFFFFFFF);
1583 if (res ==
FR_OK && clst != 0) {
1609 static DWORD clmt_clust (
1614 DWORD cl, ncl, *tbl;
1618 tbl = fp->cltbl + 1;
1622 if (ncl == 0)
return 0;
1623 if (cl < ncl)
break;
1655 for (szb = ((
DWORD)fs->
csize *
SS(fs) >= MAX_MALLOC) ? MAX_MALLOC : fs->
csize *
SS(fs), ibuf = 0; szb >
SS(fs) && (ibuf = ff_memalloc(szb)) == 0; szb /= 2) ;
1664 ibuf = fs->
win; szb = 1;
1703 while (ofs >= csz) {
1713 dp->
sect += ofs /
SS(fs);
1714 dp->
dir = fs->
win + (ofs %
SS(fs));
1738 if (ofs %
SS(fs) == 0) {
1741 if (dp->
clust == 0) {
1747 if ((ofs /
SS(fs) & (fs->
csize - 1)) == 0) {
1763 if (!stretch) dp->
sect = 0;
1801 if (res !=
FR_OK)
break;
1807 if (++n == nent)
break;
1812 }
while (res ==
FR_OK);
1865 static int cmp_lfn (
1866 const WCHAR* lfnbuf,
1876 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1878 for (wc = 1, s = 0; s < 13; s++) {
1879 uc =
ld_word(dir + LfnOfs[s]);
1881 if (i >=
FF_MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++])) {
1886 if (uc != 0xFFFF)
return 0;
1890 if ((dir[
LDIR_Ord] &
LLEF) && wc && lfnbuf[i])
return 0;
1896 #if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 || FF_USE_LABEL || FF_FS_EXFAT 1901 static int pick_lfn (
1914 for (wc = 1, s = 0; s < 13; s++) {
1915 uc =
ld_word(dir + LfnOfs[s]);
1918 lfnbuf[i++] = wc = uc;
1920 if (uc != 0xFFFF)
return 0;
1939 static void put_lfn (
1958 if (wc != 0xFFFF) wc = lfn[i++];
1960 if (wc == 0) wc = 0xFFFF;
1962 if (wc == 0xFFFF || !lfn[i]) ord |=
LLEF;
1971 #if FF_USE_LFN && !FF_FS_READONLY 1976 static void gen_numname (
1995 for (i = 0; i < 16; i++) {
1996 sr = (sr << 1) + (wc & 1);
1998 if (sr & 0x10000) sr ^= 0x11021;
2007 c = (
BYTE)((seq % 16) +
'0');
2008 if (c >
'9') c += 7;
2015 for (j = 0; j < i && dst[j] !=
' '; j++) {
2017 if (j == i - 1)
break;
2022 dst[j++] = (i < 8) ? ns[i++] :
' ';
2034 static BYTE sum_sfn (
2042 sum = (sum >> 1) + (sum << 7) + *dir++;
2056 static WORD xdir_sum (
2065 for (i = sum = 0; i < szblk; i++) {
2069 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + dir[i];
2077 static WORD xname_sum (
2085 while ((chr = *name++) != 0) {
2086 chr = (
WCHAR)ff_wtoupper(chr);
2087 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr & 0xFF);
2088 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr >> 8);
2094 #if !FF_FS_READONLY && FF_USE_MKFS 2095 static DWORD xsum32 (
2100 sum = ((sum & 1) ? 0x80000000 : 0) + (sum >> 1) + dat;
2106 #if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 2111 static void get_xfileinfo (
2121 nc = 0; hs = 0; di = 0;
2123 if (si >= MAXDIRB(
FF_MAX_LFN)) { di = 0;
break; }
2124 if ((si %
SZDIRE) == 0) si += 2;
2125 wc =
ld_word(dirb + si); si += 2; nc++;
2130 if (wc == 0) { di = 0;
break; }
2134 if (hs != 0) di = 0;
2135 if (di == 0) fno->
fname[di++] =
'?';
2137 fno->altname[0] = 0;
2163 if (res !=
FR_OK)
return res;
2172 if (res !=
FR_OK)
return res;
2174 if (res !=
FR_OK)
return res;
2184 if (res !=
FR_OK)
return res;
2186 if (res !=
FR_OK)
return res;
2189 }
while ((i += SZDIRE) < sz_ent);
2203 static void init_alloc_info (
2216 #if !FF_FS_READONLY || FF_FS_RPATH != 0 2221 static FRESULT load_obj_xdir (
2234 dp->blk_ofs = obj->c_ofs;
2236 res =
dir_sdi(dp, dp->blk_ofs);
2238 res = load_xdir(dp);
2263 res =
dir_sdi(dp, dp->blk_ofs);
2264 while (res ==
FR_OK) {
2266 if (res !=
FR_OK)
break;
2269 if (--nent == 0)
break;
2282 static void create_xdir (
2299 nlen = nc1 = 0; wc = 1;
2301 dirb[i++] = 0xC1; dirb[i++] = 0;
2303 if (wc != 0 && (wc = lfn[nlen]) != 0) nlen++;
2306 }
while (i %
SZDIRE != 0);
2308 }
while (lfn[nlen]);
2320 #if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 || FF_USE_LABEL || FF_FS_EXFAT 2325 #define dir_read_file(dp) dir_read(dp, 0) 2326 #define dir_read_label(dp) dir_read(dp, 1) 2337 BYTE ord = 0xFF, sum = 0xFF;
2342 if (res !=
FR_OK)
break;
2350 if (c == 0x83)
break;
2353 dp->blk_ofs = dp->
dptr;
2354 res = load_xdir(dp);
2372 c &= (
BYTE)~LLEF; ord = c;
2373 dp->blk_ofs = dp->
dptr;
2376 ord = (c == ord && sum == dp->
dir[
LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->
dir)) ? ord - 1 : 0xFF;
2378 if (ord != 0 || sum != sum_sfn(dp->
dir)) {
2379 dp->blk_ofs = 0xFFFFFFFF;
2391 if (res !=
FR_OK)
break;
2418 if (res !=
FR_OK)
return res;
2423 WORD hash = xname_sum(fs->lfnbuf);
2426 #if FF_MAX_LFN < 255 2430 for (nc = fs->dirbuf[
XDIR_NumName], di =
SZDIRE * 2, ni = 0; nc; nc--, di += 2, ni++) {
2431 if ((di %
SZDIRE) == 0) di += 2;
2432 if (ff_wtoupper(
ld_word(fs->dirbuf + di)) != ff_wtoupper(fs->lfnbuf[ni]))
break;
2434 if (nc == 0 && !fs->lfnbuf[ni])
break;
2441 ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF;
2445 if (res !=
FR_OK)
break;
2451 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF;
2457 c &= (
BYTE)~LLEF; ord = c;
2458 dp->blk_ofs = dp->
dptr;
2461 ord = (c == ord && sum == dp->
dir[
LDIR_Chksum] && cmp_lfn(fs->lfnbuf, dp->
dir)) ? ord - 1 : 0xFF;
2464 if (ord == 0 && sum == sum_sfn(dp->
dir))
break;
2466 ord = 0xFF; dp->blk_ofs = 0xFFFFFFFF;
2474 }
while (res ==
FR_OK);
2499 for (nlen = 0; fs->lfnbuf[nlen]; nlen++) ;
2503 nent = (nlen + 14) / 15 + 2;
2505 if (res !=
FR_OK)
return res;
2506 dp->blk_ofs = dp->
dptr -
SZDIRE * (nent - 1);
2510 res = fill_first_frag(&dp->
obj);
2511 if (res !=
FR_OK)
return res;
2512 res = fill_last_frag(&dp->
obj, dp->
clust, 0xFFFFFFFF);
2513 if (res !=
FR_OK)
return res;
2517 res = load_obj_xdir(&dj, &dp->
obj);
2518 if (res !=
FR_OK)
return res;
2523 res = store_xdir(&dj);
2524 if (res !=
FR_OK)
return res;
2528 create_xdir(fs->dirbuf, fs->lfnbuf);
2536 for (n = 1; n < 100; n++) {
2537 gen_numname(dp->
fn, sn, fs->lfnbuf, n);
2539 if (res !=
FR_OK)
break;
2547 nent = (sn[
NSFLAG] &
NS_LFN) ? (nlen + 12) / 13 + 1 : 1;
2549 if (res ==
FR_OK && --nent) {
2552 sum = sum_sfn(dp->
fn);
2555 if (res !=
FR_OK)
break;
2556 put_lfn(fs->lfnbuf, dp->
dir, (
BYTE)nent, sum);
2559 }
while (res ==
FR_OK && --nent);
2588 #if !FF_FS_READONLY && FF_FS_MINIMIZE == 0 2602 res = (dp->blk_ofs == 0xFFFFFFFF) ?
FR_OK :
dir_sdi(dp, dp->blk_ofs);
2606 if (res !=
FR_OK)
break;
2613 if (dp->
dptr >= last)
break;
2615 }
while (res ==
FR_OK);
2634 #if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 2654 if (dp->
sect == 0)
return;
2659 get_xfileinfo(fs->dirbuf, fno);
2664 if (dp->blk_ofs != 0xFFFFFFFF) {
2666 while (fs->lfnbuf[si] != 0) {
2667 wc = fs->lfnbuf[si++];
2672 if (wc == 0) { di = 0;
break; }
2676 if (hs != 0) di = 0;
2684 if (wc ==
' ')
continue;
2686 if (si == 9 && di <
FF_SFN_BUF) fno->altname[di++] =
'.';
2687 #if FF_LFN_UNICODE >= 1 2689 wc = wc << 8 | dp->
dir[si++];
2692 if (wc == 0) { di = 0;
break; }
2693 wc = put_utf(wc, &fno->altname[di],
FF_SFN_BUF - di);
2694 if (wc == 0) { di = 0;
break; }
2697 fno->altname[di++] = (
TCHAR)wc;
2700 fno->altname[di] = 0;
2702 if (fno->
fname[0] == 0) {
2704 fno->
fname[di++] =
'?';
2706 for (si = di = 0; fno->altname[si]; si++, di++) {
2707 wc = (
WCHAR)fno->altname[si];
2720 if (c ==
' ')
continue;
2722 if (si == 9) fno->
fname[di++] =
'.';
2723 fno->
fname[di++] = c;
2738 #if FF_USE_FIND && FF_FS_MINIMIZE <= 1 2750 #if FF_USE_LFN && FF_LFN_UNICODE >= 1 2751 chr = tchar2uni(ptr);
2752 if (chr == 0xFFFFFFFF) chr = 0;
2753 chr = ff_wtoupper(chr);
2756 chr = (
BYTE)*(*ptr)++;
2757 if (
IsLower(chr)) chr -= 0x20;
2758 #if FF_CODE_PAGE == 0 2759 if (
ExCvt && chr >= 0x80) chr =
ExCvt[chr - 0x80];
2760 #elif FF_CODE_PAGE < 900 || FF_CODE_PAGE > 1000 2761 if (chr >= 0x80) chr =
ExCvt[chr - 0x80];
2763 #if FF_CODE_PAGE == 0 || (FF_CODE_PAGE >= 900 && FF_CODE_PAGE<1000) 2781 const TCHAR *pp, *np;
2789 if (*pat == 0 && inf)
return 1;
2794 if (*pp ==
'?' || *pp ==
'*') {
2797 if (*pp++ ==
'?') nm++;
else nx = 1;
2798 }
while (*pp ==
'?' || *pp ==
'*');
2804 if (pc != nc)
break;
2805 if (pc == 0)
return 1;
2808 }
while (inf && nc);
2835 p = *path; lfn = dp->
obj.
fs->lfnbuf; di = 0;
2839 if (uc >= 0x10000) lfn[di++] = (
WCHAR)(uc >> 16);
2841 if (wc <
' ' || wc ==
'/' || wc ==
'\\')
break;
2846 while (*p ==
'/' || *p ==
'\\') p++;
2848 cf = (wc <
' ') ?
NS_LAST : 0;
2850 #if FF_FS_RPATH != 0 2851 if ((di == 1 && lfn[di - 1] ==
'.') ||
2852 (di == 2 && lfn[di - 1] ==
'.' && lfn[di - 2] ==
'.')) {
2854 for (i = 0; i < 11; i++) {
2855 dp->
fn[i] = (i < di) ?
'.' :
' ';
2863 if (wc !=
' ' && wc !=
'.')
break;
2870 for (si = 0; lfn[si] ==
' '; si++) ;
2872 while (di > 0 && lfn[di - 1] !=
'.') di--;
2879 if (wc ==
' ' || (wc ==
'.' && si != di)) {
2884 if (i >= ni || si == di) {
2891 si = di; i = 8; ni = 11; b <<= 2;
2897 #if FF_CODE_PAGE == 0 2900 if (wc & 0x80) wc =
ExCvt[wc & 0x7F];
2902 wc = ff_uni2oem(ff_wtoupper(wc),
CODEPAGE);
2904 #elif FF_CODE_PAGE < 900 || FF_CODE_PAGE > 1000 2906 if (wc & 0x80) wc =
ExCvt[wc & 0x7F];
2908 wc = ff_uni2oem(ff_wtoupper(wc),
CODEPAGE);
2917 dp->
fn[i++] = (
BYTE)(wc >> 8);
2919 if (wc == 0 ||
chk_chr(
"+,;=[]", wc)) {
2935 if (ni == 8) b <<= 2;
2936 if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) cf |=
NS_LFN;
2938 if (b & 0x01) cf |=
NS_EXT;
2956 p = *path; sfn = dp->
fn;
2959 #if FF_FS_RPATH != 0 2963 if (c !=
'.' || si >= 3)
break;
2974 if (c <=
' ')
break;
2975 if (c ==
'/' || c ==
'\\') {
2976 while (p[si] ==
'/' || p[si] ==
'\\') si++;
2979 if (c ==
'.' || i >= ni) {
2984 #if FF_CODE_PAGE == 0 2985 if (
ExCvt && c >= 0x80) {
2986 c =
ExCvt[c & 0x7F];
2988 #elif FF_CODE_PAGE < 900 || FF_CODE_PAGE > 1000 2990 c =
ExCvt[c & 0x7F];
3035 #if FF_FS_RPATH != 0 3036 if (*path !=
'/' && *path !=
'\\') {
3041 while (*path ==
'/' || *path ==
'\\') path++;
3046 #if FF_FS_RPATH != 0 3050 dp->
obj.c_scl = fs->cdc_scl;
3051 dp->
obj.c_size = fs->cdc_size;
3052 dp->
obj.c_ofs = fs->cdc_ofs;
3053 res = load_obj_xdir(&dj, &dp->
obj);
3054 if (res !=
FR_OK)
return res;
3061 if ((
UINT)*path <
' ') {
3068 if (res !=
FR_OK)
break;
3074 if (!(ns &
NS_LAST))
continue;
3092 dp->
obj.c_ofs = dp->blk_ofs;
3093 init_alloc_info(fs, &dp->
obj);
3116 const TCHAR *tp, *tt;
3119 #if FF_STR_VOLUME_ID 3125 if (!tp)
return vol;
3126 do tc = *tt++;
while ((
UINT)tc >= (
FF_USE_LFN ?
' ' :
'!') && tc !=
':');
3130 if (
IsDigit(*tp) && tp + 2 == tt) {
3133 #if FF_STR_VOLUME_ID == 1 3137 sp = VolumeStr[i]; tp = *path;
3139 c = *sp++; tc = *tp++;
3142 }
while (c && (
TCHAR)c == tc);
3143 }
while ((c || tp != tt) && ++i <
FF_VOLUMES);
3152 #if FF_STR_VOLUME_ID == 2 3156 sp = VolumeStr[i]; tp = *path;
3158 c = *sp++; tc = *(++tp);
3161 }
while (c && (
TCHAR)c == tc);
3171 #if FF_FS_RPATH != 0 3222 DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4];
3264 #if FF_MAX_SS != FF_MIN_SS 3272 if (fmt == 2 || (fmt < 2 &&
LD2PT(vol) != 0)) {
3273 for (i = 0; i < 4; i++) {
3281 fmt = bsect ?
check_fs(fs, bsect) : 3;
3282 }
while (
LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);
3326 for (i = 0; i <
SS(fs); i +=
SZDIRE) {
3327 if (fs->
win[i] == 0x81 && ld_dword(fs->
win + i + 20) == 2)
break;
3362 nclst = (tsect - sysect) / fs->
csize;
3392 #if (FF_FS_NOFSINFO & 3) != 3 3402 #if (FF_FS_NOFSINFO & 1) == 0 3405 #if (FF_FS_NOFSINFO & 2) == 0 3417 fs->lfnbuf = LfnBuf;
3419 fs->dirbuf = DirBuf;
3422 #if FF_FS_RPATH != 0 3448 if (lock_fs(obj->
fs)) {
3463 *rfs = (res ==
FR_OK) ? obj->
fs : 0;
3491 const TCHAR *rp = path;
3504 if (!ff_del_syncobj(cfs->sobj))
return FR_INT_ERR;
3517 if (opt == 0)
return FR_OK;
3540 DWORD dw, cl, bcs, clst, sc;
3562 res = chk_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
3590 init_alloc_info(fs, &fp->
obj);
3592 mem_set(fs->dirbuf + 2, 0, 30);
3593 mem_set(fs->dirbuf + 38, 0, 26);
3598 res = store_xdir(&dj);
3640 fp->
obj.lockid = inc_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
3661 fp->
obj.c_ofs = dj.blk_ofs;
3662 init_alloc_info(fs, &fp->
obj);
3692 if (res ==
FR_OK && ofs %
SS(fs)) {
3732 UINT rcnt, cc, csect;
3741 if (btr > remain) btr = (
UINT)remain;
3744 btr -= rcnt, *br += rcnt, rbuff += rcnt, fp->
fptr += rcnt) {
3745 if (fp->
fptr %
SS(fs) == 0) {
3748 if (fp->
fptr == 0) {
3753 clst = clmt_clust(fp, fp->
fptr);
3769 if (csect + cc > fs->
csize) {
3770 cc = fs->
csize - csect;
3773 #if !FF_FS_READONLY && FF_FS_MINIMIZE <= 2 3788 if (fp->
sect != sect) {
3801 if (rcnt > btr) rcnt = btr;
3831 UINT wcnt, cc, csect;
3832 const BYTE *wbuff = (
const BYTE*)buff;
3847 if (fp->
fptr %
SS(fs) == 0) {
3850 if (fp->
fptr == 0) {
3858 clst = clmt_clust(fp, fp->
fptr);
3887 if (csect + cc > fs->
csize) {
3888 cc = fs->
csize - csect;
3891 #if FF_FS_MINIMIZE <= 2 3893 if (fs->
winsect - sect < cc) {
3898 if (fp->
sect - sect < cc) {
3913 if (fp->
sect != sect &&
3922 if (wcnt > btw) wcnt = btw;
3968 res = fill_first_frag(&fp->
obj);
3970 res = fill_last_frag(&fp->
obj, fp->
clust, 0xFFFFFFFF);
3977 res = load_obj_xdir(&dj, &fp->
obj);
3987 res = store_xdir(&dj);
4041 res = dec_lock(fp->
obj.lockid);
4047 unlock_fs(fs,
FR_OK);
4057 #if FF_FS_RPATH >= 1 4072 CurrVol = (
BYTE)vol;
4083 #if FF_STR_VOLUME_ID == 2 4103 fs->cdc_scl = dj.
obj.c_scl;
4104 fs->cdc_size = dj.
obj.c_size;
4105 fs->cdc_ofs = dj.
obj.c_ofs;
4115 fs->cdc_ofs = dj.blk_ofs;
4128 #if FF_STR_VOLUME_ID == 2 4130 for (i =
FF_VOLUMES - 1; i && fs != FatFs[i]; i--) ;
4140 #if FF_FS_RPATH >= 2 4155 #if FF_STR_VOLUME_ID 4174 if (res !=
FR_OK)
break;
4176 if (res !=
FR_OK)
break;
4179 if (res !=
FR_OK)
break;
4182 if (res !=
FR_OK)
break;
4185 }
while (res ==
FR_OK);
4187 if (res !=
FR_OK)
break;
4189 for (n = 0; fno.
fname[n]; n++) ;
4193 while (n) buff[--i] = fno.
fname[--n];
4198 if (i == len) buff[--i] =
'/';
4201 #if FF_STR_VOLUME_ID >= 1 4202 for (n = 0, vp = (
const char*)VolumeStr[CurrVol]; vp[n]; n++) ;
4205 for (vl = 0; vl < n; *tp++ = (
TCHAR)vp[vl], vl++) ;
4211 *tp++ = (
TCHAR)
'0' + CurrVol;
4220 do *tp++ = buff[i++];
while (i < len);
4235 #if FF_FS_MINIMIZE <= 2 4247 DWORD clst, bcs, nsect;
4250 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
4257 res = fill_last_frag(&fp->
obj, fp->
clust, 0xFFFFFFFF);
4266 tlen = *tbl++; ulen = 2;
4271 tcl = cl; ncl = 0; ulen += 2;
4277 }
while (cl == pcl + 1);
4279 *tbl++ = ncl; *tbl++ = tcl;
4281 }
while (cl < fs->n_fatent);
4293 fp->
clust = clmt_clust(fp, ofs - 1);
4323 fp->
fptr = nsect = 0;
4327 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
4345 ofs -= bcs; fp->
fptr += bcs;
4369 nsect += (
DWORD)(ofs /
SS(fs));
4377 if (fp->
fptr %
SS(fs) && nsect != fp->
sect) {
4396 #if FF_FS_MINIMIZE <= 1 4426 dp->
obj.c_ofs = dp->blk_ofs;
4427 init_alloc_info(fs, &dp->
obj);
4443 dp->
obj.lockid = inc_lock(dp, 0);
4478 if (dp->
obj.lockid) res = dec_lock(dp->
obj.lockid);
4484 unlock_fs(fs,
FR_OK);
4543 if (res !=
FR_OK || !fno || !fno->
fname[0])
break;
4545 #if FF_USE_LFN && FF_USE_FIND == 2 4562 const TCHAR* pattern
4580 #if FF_FS_MINIMIZE == 0 4644 clst = 2; obj.
fs = fs;
4647 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
4649 if (stat == 0) nfree++;
4650 }
while (++clst < fs->n_fatent);
4663 if (res !=
FR_OK)
break;
4665 for (b = 8, bm = fs->
win[i]; b && clst; b--, clst--) {
4666 if (!(bm & 1)) nfree++;
4669 i = (i + 1) %
SS(fs);
4680 if (res !=
FR_OK)
break;
4686 if ((
ld_dword(fs->
win + i) & 0x0FFFFFFF) == 0) nfree++;
4723 if (fp->
fptr == 0) {
4731 if (res ==
FR_OK && ncl < fs->n_fatent) {
4783 if (res ==
FR_OK) res = chk_lock(&dj, 2);
4797 init_alloc_info(fs, &obj);
4805 #if FF_FS_RPATH != 0 4806 if (dclst == fs->cdir) {
4830 if (res ==
FR_OK && dclst != 0) {
4911 res = store_xdir(&dj);
4942 const TCHAR* path_old,
4943 const TCHAR* path_new
4963 res = chk_lock(&djo, 2);
4973 mem_cpy(&djn, &djo,
sizeof djo);
4988 res = store_xdir(&djn);
5016 if (res ==
FR_OK && dir[1] ==
'.') {
5046 #if FF_USE_CHMOD && !FF_FS_READONLY 5074 res = store_xdir(&dj);
5119 res = store_xdir(&dj);
5161 if (res ==
FR_OK && label) {
5176 wc = put_utf((
DWORD)hs << 16 | wc, &label[di], 4);
5177 if (wc == 0) { di = 0;
break; }
5181 if (hs != 0) di = 0;
5189 #if FF_USE_LFN && FF_LFN_UNICODE >= 1 5192 if (wc != 0) wc = put_utf(wc, &label[di], 4);
5193 if (wc == 0) { di = 0;
break; }
5196 label[di++] = (
TCHAR)wc;
5202 }
while (label[--di] ==
' ');
5213 if (res ==
FR_OK && vsn) {
5250 static const char badchr[] =
"+.,;=[]/\\\"*:<>\?|\x7F";
5263 while ((
UINT)*label >=
' ') {
5264 dc = tchar2uni(&label);
5265 if (dc >= 0x10000) {
5266 if (dc == 0xFFFFFFFF || di >= 10) {
5272 if (dc == 0 ||
chk_chr(badchr + 7, (
int)dc) || di >= 11) {
5282 while ((
UINT)*label >=
' ') {
5284 dc = tchar2uni(&label);
5285 wc = (dc < 0x10000) ? ff_uni2oem(ff_wtoupper(dc),
CODEPAGE) : 0;
5287 wc = (
BYTE)*label++;
5290 #if FF_CODE_PAGE == 0 5291 if (
ExCvt && wc >= 0x80) wc =
ExCvt[wc - 0x80];
5292 #elif FF_CODE_PAGE < 900 || FF_CODE_PAGE > 1000 5293 if (wc >= 0x80) wc =
ExCvt[wc - 0x80];
5296 if (wc == 0 ||
chk_chr(badchr + 0, (
int)wc) || di >= (
UINT)((wc >= 0x100) ? 10 : 11)) {
5299 if (wc >= 0x100) dirvn[di++] = (
BYTE)(wc >> 8);
5300 dirvn[di++] = (
BYTE)wc;
5303 while (di && dirvn[di - 1] ==
' ') di--;
5355 #if FF_USE_EXPAND && !FF_FS_READONLY 5368 DWORD n, clst, stcl, scl, ncl, tcl, lclst;
5378 tcl = (
DWORD)(fsz / n) + ((fsz & (n - 1)) ? 1 : 0);
5380 if (stcl < 2 || stcl >= fs->
n_fatent) stcl = 2;
5384 scl = find_bitmap(fs, stcl, tcl);
5389 res = change_bitmap(fs, scl, tcl, 1);
5390 lclst = scl + tcl - 1;
5398 scl = clst = stcl; ncl = 0;
5401 if (++clst >= fs->
n_fatent) clst = 2;
5403 if (n == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
5405 if (++ncl == tcl)
break;
5407 scl = clst; ncl = 0;
5409 if (clst == stcl) { res =
FR_DENIED;
break; }
5413 for (clst = scl, n = tcl; n; clst++, n--) {
5414 res =
put_fat(fs, clst, (n == 1) ? 0xFFFFFFFF : clst + 1);
5415 if (res !=
FR_OK)
break;
5471 if (btf > remain) btf = (
UINT)remain;
5473 for ( ; btf && (*func)(0, 0);
5474 fp->
fptr += rcnt, *bf += rcnt, btf -= rcnt) {
5476 if (fp->
fptr %
SS(fs) == 0) {
5478 clst = (fp->
fptr == 0) ?
5492 if (fp->
sect != sect) {
5505 if (rcnt > btf) rcnt = btf;
5506 rcnt = (*func)(dbuf + ((
UINT)fp->
fptr %
SS(fs)), rcnt);
5516 #if FF_USE_MKFS && !FF_FS_READONLY 5529 const UINT n_fats = 1;
5530 const UINT n_rootdir = 512;
5531 static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0};
5532 static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0};
5533 BYTE fmt, sys, *buf, *pte, pdrv, part;
5535 DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n;
5536 DWORD b_vol, b_fat, b_data;
5537 DWORD sz_vol, sz_rsv, sz_fat, sz_dir;
5541 #if FF_USE_TRIM || FF_FS_EXFAT 5549 if (FatFs[vol]) FatFs[vol]->
fs_type = 0;
5558 #if FF_MAX_SS != FF_MIN_SS 5570 for (szb_buf = MAX_MALLOC, buf = 0; szb_buf >= ss && (buf = ff_memalloc(szb_buf)) == 0; szb_buf /= 2) ;
5571 sz_buf = szb_buf / ss;
5577 szb_buf = sz_buf * ss;
5593 b_vol = (opt &
FM_SFD) ? 0 : 63;
5602 if ((opt &
FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au > 128) {
5618 DWORD szb_bit, szb_case, sum, nb, cl;
5625 tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1;
5631 if (sz_vol >= 0x80000) au = 64;
5632 if (sz_vol >= 0x4000000) au = 256;
5635 sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss;
5636 b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1);
5638 n_clst = (sz_vol - (b_data - b_vol)) / au;
5642 szb_bit = (n_clst + 7) / 8;
5643 tbl[0] = (szb_bit + au * ss - 1) / (au * ss);
5646 sect = b_data + au * tbl[0];
5648 st = 0; si = 0; i = 0; j = 0; szb_case = 0;
5652 ch = (
WCHAR)ff_wtoupper(si);
5656 for (j = 1; (
WCHAR)(si + j) && (
WCHAR)(si + j) == ff_wtoupper((
WCHAR)(si + j)); j++) ;
5658 ch = 0xFFFF; st = 2;
break;
5664 if (--j == 0) st = 0;
5671 sum = xsum32(buf[i + 0] = (
BYTE)ch, sum);
5672 sum = xsum32(buf[i + 1] = (
BYTE)(ch >> 8), sum);
5673 i += 2; szb_case += 2;
5674 if (si == 0 || i == szb_buf) {
5675 n = (i + ss - 1) / ss;
5680 tbl[1] = (szb_case + au * ss - 1) / (au * ss);
5684 sect = b_data; nsect = (szb_bit + ss - 1) / ss;
5685 nb = tbl[0] + tbl[1] + tbl[2];
5688 for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ;
5689 for (b = 1; nb != 0 && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ;
5690 n = (nsect > sz_buf) ? sz_buf : nsect;
5692 sect += n; nsect -= n;
5696 sect = b_fat; nsect = sz_fat;
5699 mem_set(buf, 0, szb_buf); i = 0;
5701 st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++;
5702 st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++;
5705 while (nb != 0 && i < szb_buf) {
5706 st_dword(buf + i, (nb > 1) ? cl + 1 : 0xFFFFFFFF);
5709 if (nb == 0 && j < 3) nb = tbl[j++];
5710 }
while (nb != 0 && i < szb_buf);
5711 n = (nsect > sz_buf) ? sz_buf : nsect;
5713 sect += n; nsect -= n;
5718 buf[
SZDIRE * 0 + 0] = 0x83;
5719 buf[
SZDIRE * 1 + 0] = 0x81;
5722 buf[
SZDIRE * 2 + 0] = 0x82;
5726 sect = b_data + au * (tbl[0] + tbl[1]); nsect = au;
5728 n = (nsect > sz_buf) ? sz_buf : nsect;
5731 sect += n; nsect -= n;
5736 for (n = 0; n < 2; n++) {
5755 for (i = sum = 0; i < ss; i++) {
5761 st_word(buf + ss - 2, 0xAA55);
5762 for (j = 1; j < 9; j++) {
5763 for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ;
5768 for ( ; j < 11; j++) {
5769 for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ;
5773 for (i = 0; i < ss; i += 4)
st_dword(buf + i, sum);
5785 n = sz_vol / 0x20000;
5786 for (i = 0, pau = 1; cst32[i] && cst32[i] <= n; i++, pau <<= 1) ;
5788 n_clst = sz_vol / pau;
5789 sz_fat = (n_clst * 4 + 8 + ss - 1) / ss;
5795 n = sz_vol / 0x1000;
5796 for (i = 0, pau = 1; cst[i] && cst[i] <= n; i++, pau <<= 1) ;
5798 n_clst = sz_vol / pau;
5803 n = (n_clst * 3 + 1) / 2 + 3;
5805 sz_fat = (n + ss - 1) / ss;
5809 b_fat = b_vol + sz_rsv;
5810 b_data = b_fat + sz_fat * n_fats + sz_dir;
5813 n = ((b_data + sz_blk - 1) & ~(sz_blk - 1)) - b_data;
5815 sz_rsv += n; b_fat += n;
5817 sz_fat += n / n_fats;
5822 n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir) / pau;
5825 if (au == 0 && (au = pau / 2) != 0)
continue;
5831 if (au == 0 && (pau * 2) <= 64) {
5832 au = pau * 2;
continue;
5837 if (au == 0 && (au = pau * 2) <= 128)
continue;
5841 if (au == 0 && (au = pau * 2) <= 128)
continue;
5852 tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1;
5863 if (sz_vol < 0x10000) {
5907 for (i = 0; i < n_fats; i++) {
5917 n = (nsect > sz_buf) ? sz_buf : nsect;
5920 sect += n; nsect -= n;
5925 nsect = (fmt ==
FS_FAT32) ? pau : sz_dir;
5927 n = (nsect > sz_buf) ? sz_buf : nsect;
5929 sect += n; nsect -= n;
5940 if (sz_vol >= 0x10000) {
5943 sys = (fmt ==
FS_FAT16) ? 0x04 : 0x01;
5964 n = (b_vol + sz_vol) / (63 * 255);
5981 #if FF_MULTI_PARTITION 5992 UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
5993 BYTE s_hd, e_hd, *p, *buf = (
BYTE*)work;
5995 DWORD sz_disk, sz_part, s_part;
6011 for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ;
6013 e_hd = (
BYTE)(n - 1);
6015 tot_cyl = sz_disk / sz_cyl;
6020 for (i = 0; i < 4; i++, p +=
SZ_PTE) {
6021 p_cyl = (szt[i] <= 100U) ? (
DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl;
6022 if (p_cyl == 0)
continue;
6023 s_part = (
DWORD)sz_cyl * b_cyl;
6024 sz_part = (
DWORD)sz_cyl * p_cyl;
6027 s_part += 63; sz_part -= 63;
6031 e_cyl = b_cyl + p_cyl - 1;
6036 p[2] = (
BYTE)(((b_cyl >> 2) & 0xC0) | 1);
6040 p[6] = (
BYTE)(((e_cyl >> 2) & 0xC0) | 63);
6062 #if FF_USE_LFN && FF_LFN_UNICODE && (FF_STRF_ENCODE < 0 || FF_STRF_ENCODE > 3) 6063 #error Wrong FF_STRF_ENCODE setting 6080 #if FF_USE_LFN && FF_LFN_UNICODE && FF_STRF_ENCODE <= 2 6083 #if FF_USE_LFN && FF_LFN_UNICODE && FF_STRF_ENCODE == 3 6087 #if FF_USE_LFN && FF_LFN_UNICODE 6093 #if FF_STRF_ENCODE == 0 6099 if (rc != 1 || !
dbc_2nd(s[0]))
continue;
6100 wc = wc << 8 | s[0];
6103 if (dc == 0)
continue;
6104 #elif FF_STRF_ENCODE == 1 || FF_STRF_ENCODE == 2 6114 dc = ((dc & 0x3FF) + 0x40) << 10 | (wc & 0x3FF);
6122 if ((dc & 0xE0) == 0xC0) { dc &= 0x1F; ct = 1; }
6123 if ((dc & 0xF0) == 0xE0) { dc &= 0x0F; ct = 2; }
6124 if ((dc & 0xF8) == 0xF0) { dc &= 0x07; ct = 3; }
6125 if (ct == 0)
continue;
6127 if (rc != ct)
break;
6130 if ((s[rc] & 0xC0) != 0x80)
break;
6131 dc = dc << 6 | (s[
rc] & 0x3F);
6132 }
while (++rc < ct);
6133 if (rc != ct || dc < 0x80 ||
IsSurrogate(dc) || dc >= 0x110000)
continue;
6137 #if FF_LFN_UNICODE == 1 || FF_LFN_UNICODE == 3 6139 *p++ = (
TCHAR)(0xD800 | ((dc >> 10) - 0x40)); nc++;
6140 dc = 0xDC00 | (dc & 0x3FF);
6142 *p++ = (
TCHAR)dc; nc++;
6143 if (dc ==
'\n')
break;
6144 #elif FF_LFN_UNICODE == 2 6148 if (dc ==
'\n')
break;
6151 *p++ = (
TCHAR)(0xC0 | (dc >> 6 & 0x1F));
6152 *p++ = (
TCHAR)(0x80 | (dc >> 0 & 0x3F));
6156 *p++ = (
TCHAR)(0xE0 | (dc >> 12 & 0x0F));
6157 *p++ = (
TCHAR)(0x80 | (dc >> 6 & 0x3F));
6158 *p++ = (
TCHAR)(0x80 | (dc >> 0 & 0x3F));
6161 *p++ = (
TCHAR)(0xF0 | (dc >> 18 & 0x07));
6162 *p++ = (
TCHAR)(0x80 | (dc >> 12 & 0x3F));
6163 *p++ = (
TCHAR)(0x80 | (dc >> 6 & 0x3F));
6164 *p++ = (
TCHAR)(0x80 | (dc >> 0 & 0x3F));
6179 *p++ = (
TCHAR)dc; nc++;
6180 if (dc ==
'\n')
break;
6185 return nc ? buff : 0;
6200 #if FF_USE_LFN && FF_LFN_UNICODE == 1 6202 #elif FF_USE_LFN && FF_LFN_UNICODE == 2 6218 #if FF_USE_LFN && FF_LFN_UNICODE 6220 #if FF_LFN_UNICODE == 2 6234 #if FF_USE_LFN && FF_LFN_UNICODE 6235 #if FF_LFN_UNICODE == 1 6239 hs = pb->hs; pb->hs = 0;
6246 #elif FF_LFN_UNICODE == 2 6249 pb->bs[pb->wi = 0] = (
BYTE)c;
6250 if ((
BYTE)c < 0x80)
break;
6251 if (((
BYTE)c & 0xE0) == 0xC0) pb->ct = 1;
6252 if (((
BYTE)c & 0xF0) == 0xE0) pb->ct = 2;
6253 if (((
BYTE)c & 0xF1) == 0xF0) pb->ct = 3;
6256 if (((
BYTE)c & 0xC0) != 0x80) {
6257 pb->ct = 0;
continue;
6259 pb->bs[++pb->wi] = (
BYTE)c;
6260 if (--pb->ct == 0)
break;
6264 tp = (
TCHAR*)pb->bs;
6265 dc = tchar2uni(&tp);
6266 if (dc == 0xFFFFFFFF)
return;
6268 hs = (
WCHAR)(dc >> 16);
6269 #elif FF_LFN_UNICODE == 3 6272 hs = (
WCHAR)(0xD800 | ((c >> 10) - 0x40));
6273 wc = 0xDC00 | (c & 0x3FF);
6280 #if FF_STRF_ENCODE == 1 6288 #elif FF_STRF_ENCODE == 2 6290 pb->
buf[i++] = (
BYTE)(hs >> 8);
6294 pb->
buf[i++] = (
BYTE)(wc >> 8);
6296 #elif FF_STRF_ENCODE == 3 6299 hs = (hs & 0x3FF) + 0x40;
6300 pb->
buf[i++] = (
BYTE)(0xF0 | hs >> 8);
6301 pb->
buf[i++] = (
BYTE)(0x80 | (hs >> 2 & 0x3F));
6302 pb->
buf[i++] = (
BYTE)(0x80 | (hs & 3) << 4 | (wc >> 6 & 0x0F));
6303 pb->
buf[i++] = (
BYTE)(0x80 | (wc & 0x3F));
6310 pb->
buf[i++] = (
BYTE)(0xC0 | wc >> 6);
6313 pb->
buf[i++] = (
BYTE)(0xE0 | wc >> 12);
6314 pb->
buf[i++] = (
BYTE)(0x80 | (wc >> 6 & 0x3F));
6316 pb->
buf[i++] = (
BYTE)(0x80 | (wc & 0x3F));
6320 if (hs != 0)
return;
6322 if (wc == 0)
return;;
6324 pb->
buf[i++] = (
BYTE)(wc >> 8); nc++;
6333 if (i >= (
int)(
sizeof pb->
buf) - 4) {
6335 i = (n == (
UINT)i) ? 0 : -1;
6397 while (*str)
putc_bfd(&pb, *str++);
6419 TCHAR c, d, str[32], *p;
6443 w = va_arg(arp,
int);
6447 w = w * 10 + c -
'0';
6451 if (c ==
'l' || c ==
'L') {
6459 p = va_arg(arp,
TCHAR*);
6460 for (j = 0; p[j]; j++) ;
6462 while (j++ < w)
putc_bfd(&pb,
' ') ;
6465 while (j++ < w)
putc_bfd(&pb,
' ') ;
6489 v = (f & 4) ? (
DWORD)va_arg(arp,
long) : ((d ==
'D') ? (
DWORD)(long)va_arg(arp,
int) : (
DWORD)va_arg(arp,
unsigned int));
6490 if (d ==
'D' && (v & 0x80000000)) {
6496 d = (
TCHAR)(v % r); v /= r;
6497 if (d > 9) d += (c ==
'x') ? 0x27 : 0x07;
6499 }
while (v && i <
sizeof str /
sizeof *str);
6500 if (f & 8) str[i++] =
'-';
6501 j = i; d = (f & 1) ?
'0' :
' ';
6521 #if FF_CODE_PAGE == 0 6530 static const WORD validcp[] = { 437, 720, 737, 771, 775, 850, 852, 857, 860, 861, 862, 863, 864, 865, 866, 869, 932, 936, 949, 950, 0};
6531 static const BYTE*
const tables[] = {Ct437, Ct720, Ct737, Ct771, Ct775, Ct850, Ct852, Ct857, Ct860, Ct861, Ct862, Ct863, Ct864, Ct865, Ct866, Ct869, Dc932, Dc936, Dc949, Dc950, 0};
6535 for (i = 0; validcp[i] != 0 && validcp[i] != cp; i++) ;
FRESULT f_chdrive(const TCHAR *path)
static DWORD create_chain(FFOBJID *obj, DWORD clst)
FRESULT f_closedir(DIR *dp)
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
static int mem_cmp(const void *dst, const void *src, UINT cnt)
FRESULT f_mkfs(const TCHAR *path, BYTE opt, DWORD au, void *work, UINT len)
static DWORD clst2sect(FATFS *fs, DWORD clst)
static FRESULT remove_chain(FFOBJID *obj, DWORD clst, DWORD pclst)
FRESULT f_unlink(const TCHAR *path)
FRESULT f_fdisk(BYTE pdrv, const DWORD *szt, void *work)
FRESULT f_findfirst(DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern)
static void mem_set(void *dst, BYTE val, UINT cnt)
FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *vsn)
#define XDIR_ValidFileSize
static DWORD ld_dword(const BYTE *ptr)
#define LEAVE_FF(fs, res)
DWORD clust2sect(FATFS *fs, DWORD clst)
int f_puts(const TCHAR *str, FIL *fp)
FRESULT f_chdir(const TCHAR *path)
FRESULT f_chmod(const TCHAR *path, BYTE attr, BYTE mask)
static FRESULT validate(FFOBJID *obj, FATFS **rfs)
static void st_word(BYTE *ptr, WORD val)
static FRESULT dir_alloc(DIR *dp, UINT nent)
FRESULT f_truncate(FIL *fp)
TCHAR * f_gets(TCHAR *buff, int len, FIL *fp)
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
static DWORD get_fat(FFOBJID *obj, DWORD clst)
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *, UINT), UINT btf, UINT *bf)
DSTATUS disk_status(BYTE pdrv)
static FATFS * FatFs[FF_VOLUMES]
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)
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
static DWORD ld_clust(FATFS *fs, const BYTE *dir)
int f_printf(FIL *fp, const TCHAR *fmt,...)
#define dir_read_label(dp)
static int chk_chr(const char *str, int chr)
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
static FRESULT sync_window(FATFS *fs)
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
static FRESULT sync_fs(FATFS *fs)
DSTATUS disk_initialize(BYTE pdrv)
static int dbc_2nd(BYTE c)
static int dbc_1st(BYTE c)
static FRESULT follow_path(DIR *dp, const TCHAR *path)
static FRESULT dir_find(DIR *dp)
#define FF_MULTI_PARTITION
FRESULT f_findnext(DIR *dp, FILINFO *fno)
static FRESULT dir_sdi(DIR *dp, DWORD ofs)
FRESULT f_opendir(DIR *dp, const TCHAR *path)
int stat(const char *name, struct stat *buf)
Display struct stat, from POSIX stat(0 or fstat(), in ASCII. NOT POSIX.
FRESULT f_setlabel(const TCHAR *label)
static FRESULT create_name(DIR *dp, const TCHAR **path)
#define dir_read_file(dp)
static FRESULT dir_remove(DIR *dp)
static void putc_init(putbuff *pb, FIL *fp)
FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
FRESULT f_mkdir(const TCHAR *path)
static FRESULT move_window(FATFS *fs, DWORD sector)
static const BYTE ExCvt[]
static int pattern_matching(const TCHAR *pat, const TCHAR *nam, int skip, int inf)
static void get_fileinfo(DIR *dp, FILINFO *fno)
int f_putc(TCHAR c, FIL *fp)
FRESULT f_expand(FIL *fp, FSIZE_t szf, BYTE opt)
static FRESULT dir_read(DIR *dp, int vol)
static void st_clust(FATFS *fs, BYTE *dir, DWORD cl)
static FRESULT dir_next(DIR *dp, int stretch)
FRESULT find_volume(const TCHAR **path, FATFS **rfs, BYTE mode)
static WORD ld_word(const BYTE *ptr)
static FRESULT dir_register(DIR *dp)
static BYTE check_fs(FATFS *fs, DWORD sect)
static FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
static int get_ldnumber(const TCHAR **path)
static void st_dword(BYTE *ptr, DWORD val)
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
static void putc_bfd(putbuff *pb, TCHAR c)
FRESULT f_getcwd(TCHAR *buff, UINT len)
static void mem_cpy(void *dst, const void *src, UINT cnt)
static int putc_flush(putbuff *pb)
static DWORD get_achar(const TCHAR **ptr)
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
static FRESULT dir_clear(FATFS *fs, DWORD clst)