Changeset 434
- Timestamp:
- Jul 5, 2020, 10:12:16 PM (3 years ago)
- Location:
- EcnlProtoTool/trunk/ntshell
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/fatfs/ccsbcs.c
r321 r434 25 25 26 26 27 #if _CODE_PAGE == 43727 #if FF_CODE_PAGE == 437 28 28 #define _TBLDEF 1 29 29 static … … 39 39 }; 40 40 41 #elif _CODE_PAGE == 72041 #elif FF_CODE_PAGE == 720 42 42 #define _TBLDEF 1 43 43 static … … 53 53 }; 54 54 55 #elif _CODE_PAGE == 73755 #elif FF_CODE_PAGE == 737 56 56 #define _TBLDEF 1 57 57 static … … 67 67 }; 68 68 69 #elif _CODE_PAGE == 77169 #elif FF_CODE_PAGE == 771 70 70 #define _TBLDEF 1 71 71 static … … 81 81 }; 82 82 83 #elif _CODE_PAGE == 77583 #elif FF_CODE_PAGE == 775 84 84 #define _TBLDEF 1 85 85 static … … 95 95 }; 96 96 97 #elif _CODE_PAGE == 85097 #elif FF_CODE_PAGE == 850 98 98 #define _TBLDEF 1 99 99 static … … 109 109 }; 110 110 111 #elif _CODE_PAGE == 852111 #elif FF_CODE_PAGE == 852 112 112 #define _TBLDEF 1 113 113 static … … 123 123 }; 124 124 125 #elif _CODE_PAGE == 855125 #elif FF_CODE_PAGE == 855 126 126 #define _TBLDEF 1 127 127 static … … 137 137 }; 138 138 139 #elif _CODE_PAGE == 857139 #elif FF_CODE_PAGE == 857 140 140 #define _TBLDEF 1 141 141 static … … 151 151 }; 152 152 153 #elif _CODE_PAGE == 860153 #elif FF_CODE_PAGE == 860 154 154 #define _TBLDEF 1 155 155 static … … 165 165 }; 166 166 167 #elif _CODE_PAGE == 861167 #elif FF_CODE_PAGE == 861 168 168 #define _TBLDEF 1 169 169 static … … 179 179 }; 180 180 181 #elif _CODE_PAGE == 862181 #elif FF_CODE_PAGE == 862 182 182 #define _TBLDEF 1 183 183 static … … 193 193 }; 194 194 195 #elif _CODE_PAGE == 863195 #elif FF_CODE_PAGE == 863 196 196 #define _TBLDEF 1 197 197 static … … 207 207 }; 208 208 209 #elif _CODE_PAGE == 864209 #elif FF_CODE_PAGE == 864 210 210 #define _TBLDEF 1 211 211 static … … 221 221 }; 222 222 223 #elif _CODE_PAGE == 865223 #elif FF_CODE_PAGE == 865 224 224 #define _TBLDEF 1 225 225 static … … 235 235 }; 236 236 237 #elif _CODE_PAGE == 866237 #elif FF_CODE_PAGE == 866 238 238 #define _TBLDEF 1 239 239 static … … 249 249 }; 250 250 251 #elif _CODE_PAGE == 869251 #elif FF_CODE_PAGE == 869 252 252 #define _TBLDEF 1 253 253 static … … 266 266 267 267 268 #if _CODE_PAGE != 65001 && (!_TBLDEF || !_USE_LFN)268 #if FF_CODE_PAGE != 65001 && (!_TBLDEF || !FF_USE_LFN) 269 269 #error This file is not needed at current configuration. Remove from the project. 270 270 #endif … … 272 272 273 273 274 #if _CODE_PAGE != 65001274 #if FF_CODE_PAGE != 65001 275 275 WCHAR ff_convert ( /* Converted character, Returns zero on error */ 276 276 WCHAR chr, /* Character code to be converted */ -
EcnlProtoTool/trunk/ntshell/fatfs/diskio.c
r321 r434 35 35 int get_status(volatile RD_STAT *stat) { 36 36 stat->sz_sector = SS_RAMDISK; 37 if(stat->sz_sector < _MIN_SS || stat->sz_sector >_MAX_SS) return 0;37 if(stat->sz_sector < FF_MIN_SS || stat->sz_sector > FF_MAX_SS) return 0; 38 38 stat->n_sectors = SZ_RAMDISK * 1024 / SS_RAMDISK; 39 39 stat->status = 0; -
EcnlProtoTool/trunk/ntshell/fatfs/diskio.h
r426 r434 60 60 61 61 /* Generic command (Used by FatFs) */ 62 #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */63 #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */64 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS !=_MIN_SS) */65 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */66 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */62 #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ 63 #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ 64 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ 65 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ 66 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ 67 67 68 68 /* Generic command (Not used by FatFs) */ -
EcnlProtoTool/trunk/ntshell/fatfs/ff.c
r331 r434 34 34 35 35 /* Reentrancy related */ 36 #if _FS_REENTRANT37 #if _USE_LFN == 136 #if FF_FS_REENTRANT 37 #if FF_USE_LFN == 1 38 38 #error Static LFN work area cannot be used at thread-safe configuration 39 39 #endif … … 49 49 50 50 /* Definitions of sector size */ 51 #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)51 #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) 52 52 #error Wrong sector size configuration 53 53 #endif 54 #if _MAX_SS ==_MIN_SS55 #define SS(fs) ((UINT) _MAX_SS) /* Fixed sector size */54 #if FF_MAX_SS == FF_MIN_SS 55 #define SS(fs) ((UINT)FF_MAX_SS) /* Fixed sector size */ 56 56 #else 57 57 #define SS(fs) ((fs)->ssize) /* Variable sector size */ … … 60 60 61 61 /* Timestamp feature */ 62 #if _FS_NORTC == 163 #if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 ||_NORTC_MDAY > 3164 #error Invalid _FS_NORTC settings65 #endif 66 #define GET_FATTIME() ((DWORD)( _NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16)62 #if FF_FS_NORTC == 1 63 #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 64 #error Invalid FF_FS_NORTC settings 65 #endif 66 #define GET_FATTIME() ((DWORD)(FF_NORTC_YEAR - 1980) << 25 | (DWORD)FF_NORTC_MON << 21 | (DWORD)FF_NORTC_MDAY << 16) 67 67 #else 68 68 #define GET_FATTIME() get_fattime() … … 71 71 72 72 /* File access control feature */ 73 #if _FS_LOCK74 #if _FS_READONLY75 #error _FS_LOCK must be 0 at read-only configuration73 #if FF_FS_LOCK != 0 74 #if FF_FS_READONLY 75 #error FF_FS_LOCK must be 0 at read-only configuration 76 76 #endif 77 77 typedef struct { … … 87 87 /* DBCS code ranges and SBCS upper conversion tables */ 88 88 89 #if _CODE_PAGE == 932 /* Japanese Shift-JIS */89 #if FF_CODE_PAGE == 932 /* Japanese Shift-JIS */ 90 90 #define _DF1S 0x81 /* DBC 1st byte range 1 start */ 91 91 #define _DF1E 0x9F /* DBC 1st byte range 1 end */ … … 97 97 #define _DS2E 0xFC /* DBC 2nd byte range 2 end */ 98 98 99 #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */99 #elif FF_CODE_PAGE == 936 /* Simplified Chinese GBK */ 100 100 #define _DF1S 0x81 101 101 #define _DF1E 0xFE … … 105 105 #define _DS2E 0xFE 106 106 107 #elif _CODE_PAGE == 949 /* Korean */107 #elif FF_CODE_PAGE == 949 /* Korean */ 108 108 #define _DF1S 0x81 109 109 #define _DF1E 0xFE … … 115 115 #define _DS3E 0xFE 116 116 117 #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */117 #elif FF_CODE_PAGE == 950 /* Traditional Chinese Big5 */ 118 118 #define _DF1S 0x81 119 119 #define _DF1E 0xFE … … 123 123 #define _DS2E 0xFE 124 124 125 #elif _CODE_PAGE == 437 /* U.S. */125 #elif FF_CODE_PAGE == 437 /* U.S. */ 126 126 #define _DF1S 0 127 127 #define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ … … 134 134 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 135 135 136 #elif _CODE_PAGE == 720 /* Arabic */136 #elif FF_CODE_PAGE == 720 /* Arabic */ 137 137 #define _DF1S 0 138 138 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 145 145 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 146 146 147 #elif _CODE_PAGE == 737 /* Greek */147 #elif FF_CODE_PAGE == 737 /* Greek */ 148 148 #define _DF1S 0 149 149 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 156 156 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 157 157 158 #elif _CODE_PAGE == 771 /* KBL */158 #elif FF_CODE_PAGE == 771 /* KBL */ 159 159 #define _DF1S 0 160 160 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 167 167 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} 168 168 169 #elif _CODE_PAGE == 775 /* Baltic */169 #elif FF_CODE_PAGE == 775 /* Baltic */ 170 170 #define _DF1S 0 171 171 #define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ … … 178 178 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 179 179 180 #elif _CODE_PAGE == 850 /* Latin 1 */180 #elif FF_CODE_PAGE == 850 /* Latin 1 */ 181 181 #define _DF1S 0 182 182 #define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ … … 189 189 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 190 190 191 #elif _CODE_PAGE == 852 /* Latin 2 */191 #elif FF_CODE_PAGE == 852 /* Latin 2 */ 192 192 #define _DF1S 0 193 193 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ … … 200 200 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} 201 201 202 #elif _CODE_PAGE == 855 /* Cyrillic */202 #elif FF_CODE_PAGE == 855 /* Cyrillic */ 203 203 #define _DF1S 0 204 204 #define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ … … 211 211 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} 212 212 213 #elif _CODE_PAGE == 857 /* Turkish */213 #elif FF_CODE_PAGE == 857 /* Turkish */ 214 214 #define _DF1S 0 215 215 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ … … 222 222 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 223 223 224 #elif _CODE_PAGE == 860 /* Portuguese */224 #elif FF_CODE_PAGE == 860 /* Portuguese */ 225 225 #define _DF1S 0 226 226 #define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ … … 233 233 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 234 234 235 #elif _CODE_PAGE == 861 /* Icelandic */235 #elif FF_CODE_PAGE == 861 /* Icelandic */ 236 236 #define _DF1S 0 237 237 #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ … … 244 244 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 245 245 246 #elif _CODE_PAGE == 862 /* Hebrew */246 #elif FF_CODE_PAGE == 862 /* Hebrew */ 247 247 #define _DF1S 0 248 248 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 255 255 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 256 256 257 #elif _CODE_PAGE == 863 /* Canadian-French */257 #elif FF_CODE_PAGE == 863 /* Canadian-French */ 258 258 #define _DF1S 0 259 259 #define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ … … 266 266 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 267 267 268 #elif _CODE_PAGE == 864 /* Arabic */268 #elif FF_CODE_PAGE == 864 /* Arabic */ 269 269 #define _DF1S 0 270 270 #define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ … … 277 277 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 278 278 279 #elif _CODE_PAGE == 865 /* Nordic */279 #elif FF_CODE_PAGE == 865 /* Nordic */ 280 280 #define _DF1S 0 281 281 #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ … … 288 288 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 289 289 290 #elif _CODE_PAGE == 866 /* Russian */290 #elif FF_CODE_PAGE == 866 /* Russian */ 291 291 #define _DF1S 0 292 292 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 299 299 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 300 300 301 #elif _CODE_PAGE == 869 /* Greek 2 */301 #elif FF_CODE_PAGE == 869 /* Greek 2 */ 302 302 #define _DF1S 0 303 303 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ … … 310 310 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} 311 311 312 #elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */313 #if _USE_LFN312 #elif FF_CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ 313 #if FF_USE_LFN 314 314 #error Cannot use LFN feature without valid code page. 315 315 #endif 316 316 #define _DF1S 0 317 317 318 #elif _CODE_PAGE == 65001 /* UTF-8 */319 #if _LFN_UNICODE318 #elif FF_CODE_PAGE == 65001 /* UTF-8 */ 319 #if FF_LFN_UNICODE 320 320 #error Cannot use LFN_UNICODE feature without valid code page. 321 321 #endif … … 532 532 */ 533 533 534 #if _VOLUMES < 1 ||_VOLUMES > 9535 #error Wrong _VOLUMES setting536 #endif 537 static FATFS *FatFs[ _VOLUMES]; /* Pointer to the file system objects (logical drives) */534 #if FF_VOLUMES < 1 || FF_VOLUMES > 9 535 #error Wrong FF_VOLUMES setting 536 #endif 537 static FATFS *FatFs[FF_VOLUMES]; /* Pointer to the file system objects (logical drives) */ 538 538 static WORD Fsid; /* File system mount ID */ 539 539 540 #if _FS_RPATH &&_VOLUMES >= 2540 #if FF_FS_RPATH && FF_VOLUMES >= 2 541 541 static BYTE CurrVol; /* Current drive */ 542 542 #endif 543 543 544 #if _FS_LOCK545 static FILESEM Files[ _FS_LOCK]; /* Open object lock semaphores */546 #endif 547 548 #if _USE_LFN == 0 /* Non LFN feature */544 #if FF_FS_LOCK != 0 545 static FILESEM Files[FF_FS_LOCK]; /* Open object lock semaphores */ 546 #endif 547 548 #if FF_USE_LFN == 0 /* Non LFN feature */ 549 549 #define DEFINE_NAMEBUF BYTE sfn[12] 550 550 #define INIT_BUF(dobj) (dobj).fn = sfn 551 551 #define FREE_BUF() 552 552 #else 553 #if _MAX_LFN < 12 ||_MAX_LFN > 255554 #error Wrong _MAX_LFN setting555 #endif 556 #if _USE_LFN == 1 /* LFN feature with static working buffer */557 static WCHAR LfnBuf[ _MAX_LFN + 1];553 #if FF_MAX_LFN < 12 || FF_MAX_LFN > 255 554 #error Wrong FF_MAX_LFN setting 555 #endif 556 #if FF_USE_LFN == 1 /* LFN feature with static working buffer */ 557 static WCHAR LfnBuf[FF_MAX_LFN + 1]; 558 558 #define DEFINE_NAMEBUF BYTE sfn[12] 559 559 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } 560 560 #define FREE_BUF() 561 #elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */562 #define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[ _MAX_LFN + 1]561 #elif FF_USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ 562 #define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR lbuf[FF_MAX_LFN + 1] 563 563 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } 564 564 #define FREE_BUF() 565 #elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */565 #elif FF_USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ 566 566 #define DEFINE_NAMEBUF BYTE sfn[12]; WCHAR *lfn 567 #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; }567 #define INIT_BUF(dobj) { lfn = ff_memalloc((FF_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; } 568 568 #define FREE_BUF() ff_memfree(lfn) 569 569 #else 570 #error Wrong _USE_LFN setting570 #error Wrong FF_USE_LFN setting 571 571 #endif 572 572 #endif … … 598 598 const BYTE *s = (const BYTE*)src; 599 599 600 #if _WORD_ACCESS == 1600 #if FF_WORD_ACCESS == 1 601 601 while (cnt >= sizeof (int)) { 602 602 *(int*)d = *(int*)s; … … 641 641 /* Request/Release grant to access the volume */ 642 642 /*-----------------------------------------------------------------------*/ 643 #if _FS_REENTRANT643 #if FF_FS_REENTRANT 644 644 static 645 645 int lock_fs ( … … 673 673 /* File lock control functions */ 674 674 /*-----------------------------------------------------------------------*/ 675 #if _FS_LOCK675 #if FF_FS_LOCK != 0 676 676 677 677 static 678 678 FRESULT chk_lock ( /* Check if the file can be accessed */ 679 DIR* dp, /* Directory object pointing the file to be checked */679 FATFS_DIR* dp, /* Directory object pointing the file to be checked */ 680 680 int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ 681 681 ) … … 684 684 685 685 /* Search file semaphore table */ 686 for (i = be = 0; i < _FS_LOCK; i++) {686 for (i = be = 0; i < FF_FS_LOCK; i++) { 687 687 if (Files[i].fs) { /* Existing entry */ 688 688 if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ … … 693 693 } 694 694 } 695 if (i == _FS_LOCK) /* The object is not opened */695 if (i == FF_FS_LOCK) /* The object is not opened */ 696 696 return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ 697 697 … … 706 706 UINT i; 707 707 708 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;709 return (i == _FS_LOCK) ? 0 : 1;708 for (i = 0; i < FF_FS_LOCK && Files[i].fs; i++) ; 709 return (i == FF_FS_LOCK) ? 0 : 1; 710 710 } 711 711 … … 713 713 static 714 714 UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ 715 DIR* dp, /* Directory object pointing the file to register or increment */715 FATFS_DIR* dp, /* Directory object pointing the file to register or increment */ 716 716 int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ 717 717 ) … … 720 720 721 721 722 for (i = 0; i < _FS_LOCK; i++) { /* Find the object */722 for (i = 0; i < FF_FS_LOCK; i++) { /* Find the object */ 723 723 if (Files[i].fs == dp->fs && 724 724 Files[i].clu == dp->sclust && … … 726 726 } 727 727 728 if (i == _FS_LOCK) { /* Not opened. Register it as new. */729 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;730 if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */728 if (i == FF_FS_LOCK) { /* Not opened. Register it as new. */ 729 for (i = 0; i < FF_FS_LOCK && Files[i].fs; i++) ; 730 if (i == FF_FS_LOCK) return 0; /* No free entry to register (int err) */ 731 731 Files[i].fs = dp->fs; 732 732 Files[i].clu = dp->sclust; … … 752 752 753 753 754 if (--i < _FS_LOCK) { /* Shift index number origin from 0 */754 if (--i < FF_FS_LOCK) { /* Shift index number origin from 0 */ 755 755 n = Files[i].ctr; 756 756 if (n == 0x100) n = 0; /* If write mode open, delete the entry */ … … 773 773 UINT i; 774 774 775 for (i = 0; i < _FS_LOCK; i++) {775 for (i = 0; i < FF_FS_LOCK; i++) { 776 776 if (Files[i].fs == fs) Files[i].fs = 0; 777 777 } … … 785 785 /* Move/Flush disk access window in the file system object */ 786 786 /*-----------------------------------------------------------------------*/ 787 #if ! _FS_READONLY787 #if !FF_FS_READONLY 788 788 static 789 789 FRESULT sync_window ( /* FR_OK:succeeded, !=0:error */ … … 825 825 826 826 if (sector != fs->winsect) { /* Window offset changed? */ 827 #if ! _FS_READONLY827 #if !FF_FS_READONLY 828 828 res = sync_window(fs); /* Write-back changes */ 829 829 #endif … … 845 845 /* Synchronize file system and strage device */ 846 846 /*-----------------------------------------------------------------------*/ 847 #if ! _FS_READONLY847 #if !FF_FS_READONLY 848 848 static 849 849 FRESULT sync_fs ( /* FR_OK:succeeded, !=0:error */ … … 959 959 /* Hidden API for hacks and disk tools */ 960 960 961 #if ! _FS_READONLY961 #if !FF_FS_READONLY 962 962 FRESULT put_fat ( /* FR_OK(0):succeeded, !=0:error */ 963 963 FATFS* fs, /* File system object */ … … 1014 1014 return res; 1015 1015 } 1016 #endif /* ! _FS_READONLY */1016 #endif /* !FF_FS_READONLY */ 1017 1017 1018 1018 … … 1022 1022 /* FAT handling - Remove a cluster chain */ 1023 1023 /*-----------------------------------------------------------------------*/ 1024 #if ! _FS_READONLY1024 #if !FF_FS_READONLY 1025 1025 static 1026 1026 FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */ … … 1031 1031 FRESULT res; 1032 1032 DWORD nxt; 1033 #if _USE_TRIM1033 #if FF_USE_TRIM 1034 1034 DWORD scl = clst, ecl = clst, rt[2]; 1035 1035 #endif … … 1051 1051 fs->fsi_flag |= 1; 1052 1052 } 1053 #if _USE_TRIM1053 #if FF_USE_TRIM 1054 1054 if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ 1055 1055 ecl = nxt; … … 1075 1075 /* FAT handling - Stretch or Create a cluster chain */ 1076 1076 /*-----------------------------------------------------------------------*/ 1077 #if ! _FS_READONLY1077 #if !FF_FS_READONLY 1078 1078 static 1079 1079 DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ … … 1128 1128 return ncl; /* Return new cluster number or error code */ 1129 1129 } 1130 #endif /* ! _FS_READONLY */1130 #endif /* !FF_FS_READONLY */ 1131 1131 1132 1132 … … 1137 1137 /*-----------------------------------------------------------------------*/ 1138 1138 1139 #if _USE_FASTSEEK1139 #if FF_USE_FASTSEEK 1140 1140 static 1141 1141 DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ … … 1157 1157 return cl + *tbl; /* Return the cluster number */ 1158 1158 } 1159 #endif /* _USE_FASTSEEK */1159 #endif /* FF_USE_FASTSEEK */ 1160 1160 1161 1161 … … 1168 1168 static 1169 1169 FRESULT dir_sdi ( /* FR_OK(0):succeeded, !=0:error */ 1170 DIR* dp, /* Pointer to directory object */1170 FATFS_DIR* dp, /* Pointer to directory object */ 1171 1171 UINT idx /* Index of directory table */ 1172 1172 ) … … 1216 1216 static 1217 1217 FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ 1218 DIR* dp, /* Pointer to the directory object */1218 FATFS_DIR* dp, /* Pointer to the directory object */ 1219 1219 int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ 1220 1220 ) … … 1222 1222 DWORD clst; 1223 1223 UINT i; 1224 #if ! _FS_READONLY1224 #if !FF_FS_READONLY 1225 1225 UINT c; 1226 1226 #endif … … 1244 1244 if (clst == 0xFFFFFFFF) return FR_DISK_ERR; 1245 1245 if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ 1246 #if ! _FS_READONLY1246 #if !FF_FS_READONLY 1247 1247 if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ 1248 1248 clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ … … 1284 1284 /*-----------------------------------------------------------------------*/ 1285 1285 1286 #if ! _FS_READONLY1286 #if !FF_FS_READONLY 1287 1287 static 1288 1288 FRESULT dir_alloc ( /* FR_OK(0):succeeded, !=0:error */ 1289 DIR* dp, /* Pointer to the directory object */1289 FATFS_DIR* dp, /* Pointer to the directory object */ 1290 1290 UINT nent /* Number of contiguous entries to allocate (1-21) */ 1291 1291 ) … … 1337 1337 1338 1338 1339 #if ! _FS_READONLY1339 #if !FF_FS_READONLY 1340 1340 static 1341 1341 void st_clust ( … … 1355 1355 /* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ 1356 1356 /*-----------------------------------------------------------------------*/ 1357 #if _USE_LFN1357 #if FF_USE_LFN 1358 1358 static 1359 1359 const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ … … 1377 1377 uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character */ 1378 1378 if (wc) { 1379 if (i >= _MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++])) /* Compare it */1379 if (i >= FF_MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++])) /* Compare it */ 1380 1380 return 0; /* Not matched */ 1381 1381 wc = uc; … … 1410 1410 uc = LD_WORD(dir + LfnOfs[s]); /* Pick an LFN character */ 1411 1411 if (wc) { 1412 if (i >= _MAX_LFN) return 0; /* Buffer overflow? */1412 if (i >= FF_MAX_LFN) return 0; /* Buffer overflow? */ 1413 1413 lfnbuf[i++] = wc = uc; /* Store it */ 1414 1414 } else { … … 1418 1418 1419 1419 if (dir[LDIR_Ord] & LLEF) { /* Put terminator if it is the last LFN part */ 1420 if (i >= _MAX_LFN) return 0; /* Buffer overflow? */1420 if (i >= FF_MAX_LFN) return 0; /* Buffer overflow? */ 1421 1421 lfnbuf[i] = 0; 1422 1422 } … … 1426 1426 1427 1427 1428 #if ! _FS_READONLY1428 #if !FF_FS_READONLY 1429 1429 static 1430 1430 void fit_lfn ( … … 1464 1464 /* Create numbered name */ 1465 1465 /*-----------------------------------------------------------------------*/ 1466 #if _USE_LFN1466 #if FF_USE_LFN 1467 1467 static 1468 1468 void gen_numname ( … … 1523 1523 /* Calculate checksum of an SFN entry */ 1524 1524 /*-----------------------------------------------------------------------*/ 1525 #if _USE_LFN1525 #if FF_USE_LFN 1526 1526 static 1527 1527 BYTE sum_sfn ( … … 1546 1546 static 1547 1547 FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */ 1548 DIR* dp /* Pointer to the directory object linked to the file name */1548 FATFS_DIR* dp /* Pointer to the directory object linked to the file name */ 1549 1549 ) 1550 1550 { 1551 1551 FRESULT res; 1552 1552 BYTE c, *dir; 1553 #if _USE_LFN1553 #if FF_USE_LFN 1554 1554 BYTE a, ord, sum; 1555 1555 #endif … … 1558 1558 if (res != FR_OK) return res; 1559 1559 1560 #if _USE_LFN1560 #if FF_USE_LFN 1561 1561 ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ 1562 1562 #endif … … 1567 1567 c = dir[DIR_Name]; 1568 1568 if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ 1569 #if _USE_LFN /* LFN configuration */1569 #if FF_USE_LFN /* LFN configuration */ 1570 1570 a = dir[DIR_Attr] & AM_MASK; 1571 1571 if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ … … 1604 1604 /* Read an object from the directory */ 1605 1605 /*-----------------------------------------------------------------------*/ 1606 #if _FS_MINIMIZE <= 1 || _USE_LABEL ||_FS_RPATH >= 21606 #if FF_FS_MINIMIZE <= 1 || FF_USE_LABEL || FF_FS_RPATH >= 2 1607 1607 static 1608 1608 FRESULT dir_read ( 1609 DIR* dp, /* Pointer to the directory object */1609 FATFS_DIR* dp, /* Pointer to the directory object */ 1610 1610 int vol /* Filtered by 0:file/directory or 1:volume label */ 1611 1611 ) … … 1613 1613 FRESULT res; 1614 1614 BYTE a, c, *dir; 1615 #if _USE_LFN1615 #if FF_USE_LFN 1616 1616 BYTE ord = 0xFF, sum = 0xFF; 1617 1617 #endif … … 1625 1625 if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ 1626 1626 a = dir[DIR_Attr] & AM_MASK; 1627 #if _USE_LFN /* LFN configuration */1628 if (c == DDEM || (! _FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */1627 #if FF_USE_LFN /* LFN configuration */ 1628 if (c == DDEM || (!FF_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */ 1629 1629 ord = 0xFF; 1630 1630 } else { … … 1644 1644 } 1645 1645 #else /* Non LFN configuration */ 1646 if (c != DDEM && ( _FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */1646 if (c != DDEM && (FF_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) /* Is it a valid entry? */ 1647 1647 break; 1648 1648 #endif … … 1655 1655 return res; 1656 1656 } 1657 #endif /* _FS_MINIMIZE <= 1 || _USE_LABEL ||_FS_RPATH >= 2 */1657 #endif /* FF_FS_MINIMIZE <= 1 || FF_USE_LABEL || FF_FS_RPATH >= 2 */ 1658 1658 1659 1659 … … 1663 1663 /* Register an object to the directory */ 1664 1664 /*-----------------------------------------------------------------------*/ 1665 #if ! _FS_READONLY1665 #if !FF_FS_READONLY 1666 1666 static 1667 1667 FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */ 1668 DIR* dp /* Target directory with object name to be created */1668 FATFS_DIR* dp /* Target directory with object name to be created */ 1669 1669 ) 1670 1670 { 1671 1671 FRESULT res; 1672 #if _USE_LFN /* LFN configuration */1672 #if FF_USE_LFN /* LFN configuration */ 1673 1673 UINT n, nent; 1674 1674 BYTE sn[12], *fn, sum; … … 1679 1679 mem_cpy(sn, fn, 12); 1680 1680 1681 if ( _FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */1681 if (FF_FS_RPATH && (sn[NSFLAG] & NS_DOT)) /* Cannot create dot entry */ 1682 1682 return FR_INVALID_NAME; 1683 1683 … … 1724 1724 mem_set(dp->dir, 0, SZ_DIRE); /* Clean the entry */ 1725 1725 mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ 1726 #if _USE_LFN1726 #if FF_USE_LFN 1727 1727 dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT); /* Put NT flag */ 1728 1728 #endif … … 1733 1733 return res; 1734 1734 } 1735 #endif /* ! _FS_READONLY */1735 #endif /* !FF_FS_READONLY */ 1736 1736 1737 1737 … … 1741 1741 /* Remove an object from the directory */ 1742 1742 /*-----------------------------------------------------------------------*/ 1743 #if ! _FS_READONLY && !_FS_MINIMIZE1743 #if !FF_FS_READONLY && !FF_FS_MINIMIZE 1744 1744 static 1745 1745 FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */ 1746 DIR* dp /* Directory object pointing the entry to be removed */1746 FATFS_DIR* dp /* Directory object pointing the entry to be removed */ 1747 1747 ) 1748 1748 { 1749 1749 FRESULT res; 1750 #if _USE_LFN /* LFN configuration */1750 #if FF_USE_LFN /* LFN configuration */ 1751 1751 UINT i; 1752 1752 … … 1780 1780 return res; 1781 1781 } 1782 #endif /* ! _FS_READONLY */1782 #endif /* !FF_FS_READONLY */ 1783 1783 1784 1784 … … 1788 1788 /* Get file information from directory entry */ 1789 1789 /*-----------------------------------------------------------------------*/ 1790 #if _FS_MINIMIZE <= 1 ||_FS_RPATH >= 21790 #if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 1791 1791 static 1792 1792 void get_fileinfo ( /* No return code */ 1793 DIR* dp, /* Pointer to the directory object */1793 FATFS_DIR* dp, /* Pointer to the directory object */ 1794 1794 FILINFO* fno /* Pointer to the file information to be filled */ 1795 1795 ) … … 1798 1798 TCHAR *p, c; 1799 1799 BYTE *dir; 1800 #if _USE_LFN1800 #if FF_USE_LFN 1801 1801 WCHAR w, *lfn; 1802 1802 #endif 1803 #if _CODE_PAGE == 650011803 #if FF_CODE_PAGE == 65001 1804 1804 unsigned char utf8_code[6]; 1805 1805 int code_size; … … 1815 1815 if (c == RDDEM) c = (TCHAR)DDEM; /* Restore replaced DDEM character */ 1816 1816 if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ 1817 #if _USE_LFN1817 #if FF_USE_LFN 1818 1818 if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) 1819 1819 c += 0x20; /* To lower */ 1820 #if _LFN_UNICODE1820 #if FF_LFN_UNICODE 1821 1821 if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) 1822 1822 c = c << 8 | dir[i++]; … … 1834 1834 *p = 0; /* Terminate SFN string by a \0 */ 1835 1835 1836 #if _USE_LFN1836 #if FF_USE_LFN 1837 1837 if (fno->lfname) { 1838 1838 i = 0; p = fno->lfname; … … 1840 1840 lfn = dp->lfn; 1841 1841 while ((w = *lfn++) != 0) { /* Get an LFN character */ 1842 #if ! _LFN_UNICODE1843 #if _CODE_PAGE == 650011842 #if !FF_LFN_UNICODE 1843 #if FF_CODE_PAGE == 65001 1844 1844 Utf16_to_Utf8(utf8_code, &code_size, w); 1845 1845 for (int j = 0; j < code_size - 1; j++) { … … 1862 1862 #endif 1863 1863 } 1864 #endif /* _FS_MINIMIZE <= 1 ||_FS_RPATH >= 2 */1864 #endif /* FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 */ 1865 1865 1866 1866 … … 1870 1870 /* Pattern matching */ 1871 1871 /*-----------------------------------------------------------------------*/ 1872 #if _USE_FIND &&_FS_MINIMIZE <= 11872 #if FF_USE_FIND && FF_FS_MINIMIZE <= 1 1873 1873 static 1874 1874 WCHAR get_achar ( /* Get a character and advances ptr 1 or 2 */ … … 1878 1878 WCHAR chr; 1879 1879 1880 #if ! _LFN_UNICODE1881 #if _CODE_PAGE == 650011880 #if !FF_LFN_UNICODE 1881 #if FF_CODE_PAGE == 65001 1882 1882 int code_size; 1883 1883 chr = Utf8_to_Utf16(*ptr, &code_size); … … 1938 1938 return 0; 1939 1939 } 1940 #endif /* _USE_FIND &&_FS_MINIMIZE <= 1 */1940 #endif /* FF_USE_FIND && FF_FS_MINIMIZE <= 1 */ 1941 1941 1942 1942 … … 1949 1949 static 1950 1950 FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */ 1951 DIR* dp, /* Pointer to the directory object */1951 FATFS_DIR* dp, /* Pointer to the directory object */ 1952 1952 const TCHAR** path /* Pointer to pointer to the segment in the path string */ 1953 1953 ) 1954 1954 { 1955 #if _USE_LFN /* LFN configuration */1955 #if FF_USE_LFN /* LFN configuration */ 1956 1956 BYTE b, cf; 1957 1957 WCHAR w, *lfn; 1958 1958 UINT i, ni, si, di; 1959 1959 const TCHAR *p; 1960 #if _CODE_PAGE == 650011961 char utf8_code[6];1960 #if FF_CODE_PAGE == 65001 1961 unsigned char utf8_code[6]; 1962 1962 int code_size; 1963 1963 #endif … … 1969 1969 w = p[si++]; /* Get a character */ 1970 1970 if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ 1971 if (di >= _MAX_LFN) /* Reject too long name */1971 if (di >= FF_MAX_LFN) /* Reject too long name */ 1972 1972 return FR_INVALID_NAME; 1973 #if ! _LFN_UNICODE1974 #if _CODE_PAGE == 650011973 #if !FF_LFN_UNICODE 1974 #if FF_CODE_PAGE == 65001 1975 1975 w = Utf8_to_Utf16(&p[si - 1], &code_size); 1976 1976 si += code_size - 1; … … 1993 1993 *path = &p[si]; /* Return pointer to the next segment */ 1994 1994 cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ 1995 #if _FS_RPATH1995 #if FF_FS_RPATH 1996 1996 if ((di == 1 && lfn[di - 1] == '.') || 1997 1997 (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) { /* Is this segment a dot entry? */ … … 2040 2040 if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ 2041 2041 #else 2042 #if _CODE_PAGE == 650012042 #if FF_CODE_PAGE == 65001 2043 2043 Utf16_to_Utf8(utf8_code, &code_size, ff_wtoupper(w)); 2044 2044 #else … … 2048 2048 cf |= NS_LFN; /* Force create LFN entry */ 2049 2049 } 2050 #if _CODE_PAGE == 650012050 #if FF_CODE_PAGE == 65001 2051 2051 else 2052 2052 code_size = 1; 2053 2053 #endif 2054 2054 2055 #if _CODE_PAGE == 650012055 #if FF_CODE_PAGE == 65001 2056 2056 if (code_size > 1) { /* Is this DBC? (always false at SBCS cfg) */ 2057 2057 if (i >= ni - 1) { … … 2126 2126 mem_set(sfn, ' ', 11); 2127 2127 si = i = b = 0; ni = 8; 2128 #if _FS_RPATH2128 #if FF_FS_RPATH 2129 2129 if (p[si] == '.') { /* Is this a dot entry? */ 2130 2130 for (;;) { … … 2201 2201 static 2202 2202 FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ 2203 DIR* dp, /* Directory object to return last directory and found object */2203 FATFS_DIR* dp, /* Directory object to return last directory and found object */ 2204 2204 const TCHAR* path /* Full-path string to find a file or directory */ 2205 2205 ) … … 2209 2209 2210 2210 2211 #if _FS_RPATH2211 #if FF_FS_RPATH 2212 2212 if (*path == '/' || *path == '\\') { /* There is a heading separator */ 2213 2213 path++; dp->sclust = 0; /* Strip it and start from the root directory */ … … 2232 2232 if (res != FR_OK) { /* Failed to find the object */ 2233 2233 if (res == FR_NO_FILE) { /* Object is not found */ 2234 if ( _FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */2234 if (FF_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ 2235 2235 dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ 2236 2236 if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ … … 2269 2269 UINT i; 2270 2270 int vol = -1; 2271 #if _STR_VOLUME_ID /* Find string drive id */2272 static const char* const str[] = { _VOLUME_STRS};2271 #if FF_STR_VOLUME_ID /* Find string drive id */ 2272 static const char* const str[] = {FF_VOLUME_STRS}; 2273 2273 const char *sp; 2274 2274 char c; … … 2278 2278 2279 2279 if (*path) { /* If the pointer is not a null */ 2280 for (tt = *path; (UINT)*tt >= ( _USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */2280 for (tt = *path; (UINT)*tt >= (FF_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ 2281 2281 if (*tt == ':') { /* If a ':' is exist in the path name */ 2282 2282 tp = *path; 2283 2283 i = *tp++ - '0'; 2284 2284 if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ 2285 if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */2285 if (i < FF_VOLUMES) { /* If a drive id is found, get the value and strip it */ 2286 2286 vol = (int)i; 2287 2287 *path = ++tt; 2288 2288 } 2289 2289 } 2290 #if _STR_VOLUME_ID2290 #if FF_STR_VOLUME_ID 2291 2291 else { /* No numeric drive number, find string drive id */ 2292 2292 i = 0; tt++; … … 2297 2297 if (IsLower(tc)) tc -= 0x20; 2298 2298 } while (c && (TCHAR)c == tc); 2299 } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */2300 if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */2299 } while ((c || tp != tt) && ++i < FF_VOLUMES); /* Repeat for each id until pattern match */ 2300 if (i < FF_VOLUMES) { /* If a drive id is found, get the value and strip it */ 2301 2301 vol = (int)i; 2302 2302 *path = tt; … … 2306 2306 return vol; 2307 2307 } 2308 #if _FS_RPATH &&_VOLUMES >= 22308 #if FF_FS_RPATH && FF_VOLUMES >= 2 2309 2309 vol = CurrVol; /* Current drive */ 2310 2310 #else … … 2381 2381 stat = disk_status(fs->drv); 2382 2382 if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ 2383 if (! _FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */2383 if (!FF_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ 2384 2384 return FR_WRITE_PROTECTED; 2385 2385 return FR_OK; /* The file system object is valid */ … … 2395 2395 if (stat & STA_NOINIT) /* Check if the initialization succeeded */ 2396 2396 return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ 2397 if (! _FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */2397 if (!FF_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ 2398 2398 return FR_WRITE_PROTECTED; 2399 #if _MAX_SS !=_MIN_SS /* Get sector size (multiple sector size cfg only) */2399 #if FF_MAX_SS != FF_MIN_SS /* Get sector size (multiple sector size cfg only) */ 2400 2400 if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK 2401 || SS(fs) < _MIN_SS || SS(fs) >_MAX_SS) return FR_DISK_ERR;2401 || SS(fs) < FF_MIN_SS || SS(fs) > FF_MAX_SS) return FR_DISK_ERR; 2402 2402 #endif 2403 2403 /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ … … 2448 2448 2449 2449 /* Determine the FAT sub type */ 2450 sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + DIR */2450 sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE); /* RSV + FAT + FATFS_DIR */ 2451 2451 if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ 2452 2452 nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ … … 2474 2474 return FR_NO_FILESYSTEM; 2475 2475 2476 #if ! _FS_READONLY2476 #if !FF_FS_READONLY 2477 2477 /* Initialize cluster allocation information */ 2478 2478 fs->last_clust = fs->free_clust = 0xFFFFFFFF; … … 2480 2480 /* Get fsinfo if available */ 2481 2481 fs->fsi_flag = 0x80; 2482 #if ( _FS_NOFSINFO & 3) != 32482 #if (FF_FS_NOFSINFO & 3) != 3 2483 2483 if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo == 1 */ 2484 2484 && LD_WORD(fs->win + BPB_FSInfo) == 1 … … 2490 2490 && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272) 2491 2491 { 2492 #if ( _FS_NOFSINFO & 1) == 02492 #if (FF_FS_NOFSINFO & 1) == 0 2493 2493 fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count); 2494 2494 #endif 2495 #if ( _FS_NOFSINFO & 2) == 02495 #if (FF_FS_NOFSINFO & 2) == 0 2496 2496 fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free); 2497 2497 #endif … … 2502 2502 fs->fs_type = fmt; /* FAT sub-type */ 2503 2503 fs->id = ++Fsid; /* File system mount ID */ 2504 #if _FS_RPATH2504 #if FF_FS_RPATH 2505 2505 fs->cdir = 0; /* Set current directory to root */ 2506 2506 #endif 2507 #if _FS_LOCK/* Clear file lock semaphores */2507 #if FF_FS_LOCK != 0 /* Clear file lock semaphores */ 2508 2508 clear_lock(fs); 2509 2509 #endif … … 2521 2521 static 2522 2522 FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ 2523 void* obj /* Pointer to the object FIL/ DIR to check validity */2524 ) 2525 { 2526 FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/ DIR structure is identical */2523 void* obj /* Pointer to the object FIL/FATFS_DIR to check validity */ 2524 ) 2525 { 2526 FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/FATFS_DIR structure is identical */ 2527 2527 2528 2528 … … 2567 2567 2568 2568 if (cfs) { 2569 #if _FS_LOCK2569 #if FF_FS_LOCK != 0 2570 2570 clear_lock(cfs); 2571 2571 #endif 2572 #if _FS_REENTRANT /* Discard sync object of the current volume */2572 #if FF_FS_REENTRANT /* Discard sync object of the current volume */ 2573 2573 if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; 2574 2574 #endif … … 2578 2578 if (fs) { 2579 2579 fs->fs_type = 0; /* Clear new fs object */ 2580 #if _FS_REENTRANT /* Create sync object for the new volume */2580 #if FF_FS_REENTRANT /* Create sync object for the new volume */ 2581 2581 if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; 2582 2582 #endif … … 2604 2604 { 2605 2605 FRESULT res; 2606 DIR dj;2606 FATFS_DIR dj; 2607 2607 BYTE *dir; 2608 2608 DEFINE_NAMEBUF; 2609 #if ! _FS_READONLY2609 #if !FF_FS_READONLY 2610 2610 DWORD dw, cl; 2611 2611 #endif … … 2616 2616 2617 2617 /* Get logical drive number */ 2618 #if ! _FS_READONLY2618 #if !FF_FS_READONLY 2619 2619 mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; 2620 2620 res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); … … 2627 2627 res = follow_path(&dj, path); /* Follow the file path */ 2628 2628 dir = dj.dir; 2629 #if ! _FS_READONLY /* R/W configuration */2629 #if !FF_FS_READONLY /* R/W configuration */ 2630 2630 if (res == FR_OK) { 2631 2631 if (!dir) /* Default directory itself */ 2632 2632 res = FR_INVALID_NAME; 2633 #if _FS_LOCK2633 #if FF_FS_LOCK != 0 2634 2634 else 2635 2635 res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); … … 2640 2640 if (res != FR_OK) { /* No file, create new */ 2641 2641 if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ 2642 #if _FS_LOCK2642 #if FF_FS_LOCK != 0 2643 2643 res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; 2644 2644 #else … … 2649 2649 } 2650 2650 else { /* Any object is already existing */ 2651 if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */2651 if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or FATFS_DIR) */ 2652 2652 res = FR_DENIED; 2653 2653 } else { … … 2687 2687 if (res == FR_OK) { 2688 2688 if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ 2689 mode |= FA_ _WRITTEN;2689 mode |= FA_MODIFIED; 2690 2690 fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ 2691 2691 fp->dir_ptr = dir; 2692 #if _FS_LOCK2692 #if FF_FS_LOCK != 0 2693 2693 fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); 2694 2694 if (!fp->lockid) res = FR_INT_ERR; … … 2716 2716 fp->fptr = 0; /* File pointer */ 2717 2717 fp->dsect = 0; 2718 #if _USE_FASTSEEK2718 #if FF_USE_FASTSEEK 2719 2719 fp->cltbl = 0; /* Normal seek mode */ 2720 2720 #endif … … 2766 2766 clst = fp->sclust; /* Follow from the origin */ 2767 2767 } else { /* Middle or end of the file */ 2768 #if _USE_FASTSEEK2768 #if FF_USE_FASTSEEK 2769 2769 if (fp->cltbl) 2770 2770 clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ … … 2786 2786 if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK) 2787 2787 ABORT(fp->fs, FR_DISK_ERR); 2788 #if ! _FS_READONLY &&_FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */2789 #if _FS_TINY2788 #if !FF_FS_READONLY && FF_FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ 2789 #if FF_FS_TINY 2790 2790 if (fp->fs->wflag && fp->fs->winsect - sect < cc) 2791 2791 mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); 2792 2792 #else 2793 if ((fp->flag & FA_ _DIRTY) && fp->dsect - sect < cc)2793 if ((fp->flag & FA_DIRTY) && fp->dsect - sect < cc) 2794 2794 mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); 2795 2795 #endif … … 2798 2798 continue; 2799 2799 } 2800 #if ! _FS_TINY2800 #if !FF_FS_TINY 2801 2801 if (fp->dsect != sect) { /* Load data sector if not in cache */ 2802 #if ! _FS_READONLY2803 if (fp->flag & FA_ _DIRTY) { /* Write-back dirty sector cache */2802 #if !FF_FS_READONLY 2803 if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ 2804 2804 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 2805 2805 ABORT(fp->fs, FR_DISK_ERR); 2806 fp->flag &= ~FA_ _DIRTY;2806 fp->flag &= ~FA_DIRTY; 2807 2807 } 2808 2808 #endif … … 2815 2815 rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ 2816 2816 if (rcnt > btr) rcnt = btr; 2817 #if _FS_TINY2817 #if FF_FS_TINY 2818 2818 if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ 2819 2819 ABORT(fp->fs, FR_DISK_ERR); … … 2830 2830 2831 2831 2832 #if ! _FS_READONLY2832 #if !FF_FS_READONLY 2833 2833 /*-----------------------------------------------------------------------*/ 2834 2834 /* Write File */ … … 2869 2869 clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ 2870 2870 } else { /* Middle or end of the file */ 2871 #if _USE_FASTSEEK2871 #if FF_USE_FASTSEEK 2872 2872 if (fp->cltbl) 2873 2873 clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ … … 2882 2882 if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ 2883 2883 } 2884 #if _FS_TINY2884 #if FF_FS_TINY 2885 2885 if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ 2886 2886 ABORT(fp->fs, FR_DISK_ERR); 2887 2887 #else 2888 if (fp->flag & FA_ _DIRTY) { /* Write-back sector cache */2888 if (fp->flag & FA_DIRTY) { /* Write-back sector cache */ 2889 2889 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 2890 2890 ABORT(fp->fs, FR_DISK_ERR); 2891 fp->flag &= ~FA_ _DIRTY;2891 fp->flag &= ~FA_DIRTY; 2892 2892 } 2893 2893 #endif … … 2901 2901 if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK) 2902 2902 ABORT(fp->fs, FR_DISK_ERR); 2903 #if _FS_MINIMIZE <= 22904 #if _FS_TINY2903 #if FF_FS_MINIMIZE <= 2 2904 #if FF_FS_TINY 2905 2905 if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ 2906 2906 mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); … … 2910 2910 if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ 2911 2911 mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); 2912 fp->flag &= ~FA_ _DIRTY;2912 fp->flag &= ~FA_DIRTY; 2913 2913 } 2914 2914 #endif … … 2917 2917 continue; 2918 2918 } 2919 #if _FS_TINY2919 #if FF_FS_TINY 2920 2920 if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ 2921 2921 if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); … … 2933 2933 wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ 2934 2934 if (wcnt > btw) wcnt = btw; 2935 #if _FS_TINY2935 #if FF_FS_TINY 2936 2936 if (move_window(fp->fs, fp->dsect) != FR_OK) /* Move sector window */ 2937 2937 ABORT(fp->fs, FR_DISK_ERR); … … 2940 2940 #else 2941 2941 mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ 2942 fp->flag |= FA_ _DIRTY;2942 fp->flag |= FA_DIRTY; 2943 2943 #endif 2944 2944 } 2945 2945 2946 2946 if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ 2947 fp->flag |= FA_ _WRITTEN; /* Set file change flag */2947 fp->flag |= FA_MODIFIED; /* Set file change flag */ 2948 2948 2949 2949 LEAVE_FF(fp->fs, FR_OK); … … 2968 2968 res = validate(fp); /* Check validity of the object */ 2969 2969 if (res == FR_OK) { 2970 if (fp->flag & FA_ _WRITTEN) { /* Is there any change to the file? */2971 #if ! _FS_TINY2972 if (fp->flag & FA_ _DIRTY) { /* Write-back cached data if needed */2970 if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */ 2971 #if !FF_FS_TINY 2972 if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */ 2973 2973 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 2974 2974 LEAVE_FF(fp->fs, FR_DISK_ERR); 2975 fp->flag &= ~FA_ _DIRTY;2975 fp->flag &= ~FA_DIRTY; 2976 2976 } 2977 2977 #endif … … 2986 2986 ST_DWORD(dir + DIR_WrtTime, tm); 2987 2987 ST_WORD(dir + DIR_LstAccDate, 0); 2988 fp->flag &= ~FA_ _WRITTEN;2988 fp->flag &= ~FA_MODIFIED; 2989 2989 fp->fs->wflag = 1; 2990 2990 res = sync_fs(fp->fs); … … 2996 2996 } 2997 2997 2998 #endif /* ! _FS_READONLY */2998 #endif /* !FF_FS_READONLY */ 2999 2999 3000 3000 … … 3012 3012 3013 3013 3014 #if ! _FS_READONLY3014 #if !FF_FS_READONLY 3015 3015 res = f_sync(fp); /* Flush cached data */ 3016 3016 if (res == FR_OK) … … 3019 3019 res = validate(fp); /* Lock volume */ 3020 3020 if (res == FR_OK) { 3021 #if _FS_REENTRANT3021 #if FF_FS_REENTRANT 3022 3022 FATFS *fs = fp->fs; 3023 3023 #endif 3024 #if _FS_LOCK3024 #if FF_FS_LOCK != 0 3025 3025 res = dec_lock(fp->lockid); /* Decrement file open counter */ 3026 3026 if (res == FR_OK) 3027 3027 #endif 3028 3028 fp->fs = 0; /* Invalidate file object */ 3029 #if _FS_REENTRANT3029 #if FF_FS_REENTRANT 3030 3030 unlock_fs(fs, FR_OK); /* Unlock volume */ 3031 3031 #endif … … 3042 3042 /*-----------------------------------------------------------------------*/ 3043 3043 3044 #if _FS_RPATH >= 13045 #if _VOLUMES >= 23044 #if FF_FS_RPATH >= 1 3045 #if FF_VOLUMES >= 2 3046 3046 FRESULT f_chdrive ( 3047 3047 const TCHAR* path /* Drive number */ … … 3066 3066 { 3067 3067 FRESULT res; 3068 DIR dj;3068 FATFS_DIR dj; 3069 3069 DEFINE_NAMEBUF; 3070 3070 … … 3093 3093 3094 3094 3095 #if _FS_RPATH >= 23095 #if FF_FS_RPATH >= 2 3096 3096 FRESULT f_getcwd ( 3097 3097 TCHAR* buff, /* Pointer to the directory path */ … … 3100 3100 { 3101 3101 FRESULT res; 3102 DIR dj;3102 FATFS_DIR dj; 3103 3103 UINT i, n; 3104 3104 DWORD ccl; … … 3131 3131 if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ 3132 3132 if (res != FR_OK) break; 3133 #if _USE_LFN3133 #if FF_USE_LFN 3134 3134 fno.lfname = buff; 3135 3135 fno.lfsize = i; … … 3137 3137 get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ 3138 3138 tp = fno.fname; 3139 #if _USE_LFN3139 #if FF_USE_LFN 3140 3140 if (*buff) tp = buff; 3141 3141 #endif … … 3149 3149 tp = buff; 3150 3150 if (res == FR_OK) { 3151 #if _VOLUMES >= 23151 #if FF_VOLUMES >= 2 3152 3152 *tp++ = '0' + CurrVol; /* Put drive number */ 3153 3153 *tp++ = ':'; … … 3167 3167 LEAVE_FF(dj.fs, res); 3168 3168 } 3169 #endif /* _FS_RPATH >= 2 */3170 #endif /* _FS_RPATH >= 1 */3171 3172 3173 3174 #if _FS_MINIMIZE <= 23169 #endif /* FF_FS_RPATH >= 2 */ 3170 #endif /* FF_FS_RPATH >= 1 */ 3171 3172 3173 3174 #if FF_FS_MINIMIZE <= 2 3175 3175 /*-----------------------------------------------------------------------*/ 3176 3176 /* Seek File R/W Pointer */ … … 3184 3184 FRESULT res; 3185 3185 DWORD clst, bcs, nsect, ifptr; 3186 #if _USE_FASTSEEK3186 #if FF_USE_FASTSEEK 3187 3187 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; 3188 3188 #endif … … 3194 3194 LEAVE_FF(fp->fs, (FRESULT)fp->err); 3195 3195 3196 #if _USE_FASTSEEK3196 #if FF_USE_FASTSEEK 3197 3197 if (fp->cltbl) { /* Fast seek */ 3198 3198 if (ofs == CREATE_LINKMAP) { /* Create CLMT */ … … 3231 3231 dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); 3232 3232 if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ 3233 #if ! _FS_TINY3234 #if ! _FS_READONLY3235 if (fp->flag & FA_ _DIRTY) { /* Write-back dirty sector cache */3233 #if !FF_FS_TINY 3234 #if !FF_FS_READONLY 3235 if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ 3236 3236 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 3237 3237 ABORT(fp->fs, FR_DISK_ERR); 3238 fp->flag &= ~FA_ _DIRTY;3238 fp->flag &= ~FA_DIRTY; 3239 3239 } 3240 3240 #endif … … 3252 3252 { 3253 3253 if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ 3254 #if ! _FS_READONLY3254 #if !FF_FS_READONLY 3255 3255 && !(fp->flag & FA_WRITE) 3256 3256 #endif … … 3268 3268 } else { /* When seek to back cluster, */ 3269 3269 clst = fp->sclust; /* start from the first cluster */ 3270 #if ! _FS_READONLY3270 #if !FF_FS_READONLY 3271 3271 if (clst == 0) { /* If no cluster chain, create a new chain */ 3272 3272 clst = create_chain(fp->fs, 0); … … 3280 3280 if (clst != 0) { 3281 3281 while (ofs > bcs) { /* Cluster following loop */ 3282 #if ! _FS_READONLY3282 #if !FF_FS_READONLY 3283 3283 if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ 3284 3284 clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ … … 3304 3304 } 3305 3305 if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ 3306 #if ! _FS_TINY3307 #if ! _FS_READONLY3308 if (fp->flag & FA_ _DIRTY) { /* Write-back dirty sector cache */3306 #if !FF_FS_TINY 3307 #if !FF_FS_READONLY 3308 if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */ 3309 3309 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 3310 3310 ABORT(fp->fs, FR_DISK_ERR); 3311 fp->flag &= ~FA_ _DIRTY;3311 fp->flag &= ~FA_DIRTY; 3312 3312 } 3313 3313 #endif … … 3317 3317 fp->dsect = nsect; 3318 3318 } 3319 #if ! _FS_READONLY3319 #if !FF_FS_READONLY 3320 3320 if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ 3321 3321 fp->fsize = fp->fptr; 3322 fp->flag |= FA_ _WRITTEN;3322 fp->flag |= FA_MODIFIED; 3323 3323 } 3324 3324 #endif … … 3342 3342 } 3343 3343 3344 #if _FS_MINIMIZE <= 13344 #if FF_FS_MINIMIZE <= 1 3345 3345 /*-----------------------------------------------------------------------*/ 3346 3346 /* Create a Directory Object */ … … 3348 3348 3349 3349 FRESULT f_opendir ( 3350 DIR* dp, /* Pointer to directory object to create */3350 FATFS_DIR* dp, /* Pointer to directory object to create */ 3351 3351 const TCHAR* path /* Pointer to the directory path */ 3352 3352 ) … … 3376 3376 dp->id = fs->id; 3377 3377 res = dir_sdi(dp, 0); /* Rewind directory */ 3378 #if _FS_LOCK3378 #if FF_FS_LOCK != 0 3379 3379 if (res == FR_OK) { 3380 3380 if (dp->sclust) { … … 3404 3404 3405 3405 FRESULT f_closedir ( 3406 DIR *dp /* Pointer to the directory object to be closed */3406 FATFS_DIR *dp /* Pointer to the directory object to be closed */ 3407 3407 ) 3408 3408 { … … 3412 3412 res = validate(dp); 3413 3413 if (res == FR_OK) { 3414 #if _FS_REENTRANT3414 #if FF_FS_REENTRANT 3415 3415 FATFS *fs = dp->fs; 3416 3416 #endif 3417 #if _FS_LOCK3417 #if FF_FS_LOCK != 0 3418 3418 if (dp->lockid) /* Decrement sub-directory open counter */ 3419 3419 res = dec_lock(dp->lockid); … … 3421 3421 #endif 3422 3422 dp->fs = 0; /* Invalidate directory object */ 3423 #if _FS_REENTRANT3423 #if FF_FS_REENTRANT 3424 3424 unlock_fs(fs, FR_OK); /* Unlock volume */ 3425 3425 #endif … … 3436 3436 3437 3437 FRESULT f_readdir ( 3438 DIR* dp, /* Pointer to the open directory object */3438 FATFS_DIR* dp, /* Pointer to the open directory object */ 3439 3439 FILINFO* fno /* Pointer to file information to return */ 3440 3440 ) … … 3472 3472 3473 3473 3474 #if _USE_FIND3474 #if FF_USE_FIND 3475 3475 /*-----------------------------------------------------------------------*/ 3476 3476 /* Find next file */ … … 3478 3478 3479 3479 FRESULT f_findnext ( 3480 DIR* dp, /* Pointer to the open directory object */3480 FATFS_DIR* dp, /* Pointer to the open directory object */ 3481 3481 FILINFO* fno /* Pointer to the file information structure */ 3482 3482 ) … … 3488 3488 res = f_readdir(dp, fno); /* Get a directory item */ 3489 3489 if (res != FR_OK || !fno || !fno->fname[0]) break; /* Terminate if any error or end of directory */ 3490 #if _USE_LFN3490 #if FF_USE_LFN 3491 3491 if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */ 3492 3492 #endif … … 3504 3504 3505 3505 FRESULT f_findfirst ( 3506 DIR* dp, /* Pointer to the blank directory object */3506 FATFS_DIR* dp, /* Pointer to the blank directory object */ 3507 3507 FILINFO* fno, /* Pointer to the file information structure */ 3508 3508 const TCHAR* path, /* Pointer to the directory to open */ … … 3520 3520 } 3521 3521 3522 #endif /* _USE_FIND */3523 3524 3525 3526 #if _FS_MINIMIZE == 03522 #endif /* FF_USE_FIND */ 3523 3524 3525 3526 #if FF_FS_MINIMIZE == 0 3527 3527 /*-----------------------------------------------------------------------*/ 3528 3528 /* Get File Status */ … … 3535 3535 { 3536 3536 FRESULT res; 3537 DIR dj;3537 FATFS_DIR dj; 3538 3538 DEFINE_NAMEBUF; 3539 3539 … … 3559 3559 3560 3560 3561 #if ! _FS_READONLY3561 #if !FF_FS_READONLY 3562 3562 /*-----------------------------------------------------------------------*/ 3563 3563 /* Get Number of Free Clusters */ … … 3650 3650 if (fp->fsize > fp->fptr) { 3651 3651 fp->fsize = fp->fptr; /* Set file size to current R/W point */ 3652 fp->flag |= FA_ _WRITTEN;3652 fp->flag |= FA_MODIFIED; 3653 3653 if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ 3654 3654 res = remove_chain(fp->fs, fp->sclust); … … 3664 3664 } 3665 3665 } 3666 #if ! _FS_TINY3667 if (res == FR_OK && (fp->flag & FA_ _DIRTY)) {3666 #if !FF_FS_TINY 3667 if (res == FR_OK && (fp->flag & FA_DIRTY)) { 3668 3668 if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) 3669 3669 res = FR_DISK_ERR; 3670 3670 else 3671 fp->flag &= ~FA_ _DIRTY;3671 fp->flag &= ~FA_DIRTY; 3672 3672 } 3673 3673 #endif … … 3691 3691 { 3692 3692 FRESULT res; 3693 DIR dj, sdj;3693 FATFS_DIR dj, sdj; 3694 3694 BYTE *dir; 3695 3695 DWORD dclst = 0; … … 3702 3702 INIT_BUF(dj); 3703 3703 res = follow_path(&dj, path); /* Follow the file path */ 3704 if ( _FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))3704 if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) 3705 3705 res = FR_INVALID_NAME; /* Cannot remove dot entry */ 3706 #if _FS_LOCK3706 #if FF_FS_LOCK != 0 3707 3707 if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open object */ 3708 3708 #endif … … 3718 3718 dclst = ld_clust(dj.fs, dir); 3719 3719 if (dclst && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-directory ? */ 3720 #if _FS_RPATH3720 #if FF_FS_RPATH 3721 3721 if (dclst == dj.fs->cdir) { /* Is it the current directory? */ 3722 3722 res = FR_DENIED; … … 3724 3724 #endif 3725 3725 { 3726 mem_cpy(&sdj, &dj, sizeof ( DIR)); /* Open the sub-directory */3726 mem_cpy(&sdj, &dj, sizeof (FATFS_DIR)); /* Open the sub-directory */ 3727 3727 sdj.sclust = dclst; 3728 3728 res = dir_sdi(&sdj, 2); … … 3760 3760 { 3761 3761 FRESULT res; 3762 DIR dj;3762 FATFS_DIR dj; 3763 3763 BYTE *dir, n; 3764 3764 DWORD dsc, dcl, pcl, tm = GET_FATTIME(); … … 3772 3772 res = follow_path(&dj, path); /* Follow the file path */ 3773 3773 if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ 3774 if ( _FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT))3774 if (FF_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) 3775 3775 res = FR_INVALID_NAME; 3776 3776 if (res == FR_NO_FILE) { /* Can create a new directory */ … … 3836 3836 { 3837 3837 FRESULT res; 3838 DIR dj;3838 FATFS_DIR dj; 3839 3839 BYTE *dir; 3840 3840 DEFINE_NAMEBUF; … … 3846 3846 res = follow_path(&dj, path); /* Follow the file path */ 3847 3847 FREE_BUF(); 3848 if ( _FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))3848 if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) 3849 3849 res = FR_INVALID_NAME; 3850 3850 if (res == FR_OK) { … … 3877 3877 { 3878 3878 FRESULT res; 3879 DIR djo, djn;3879 FATFS_DIR djo, djn; 3880 3880 BYTE buf[21], *dir; 3881 3881 DWORD dw; … … 3890 3890 INIT_BUF(djo); 3891 3891 res = follow_path(&djo, path_old); /* Check old object */ 3892 if ( _FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT))3892 if (FF_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT)) 3893 3893 res = FR_INVALID_NAME; 3894 #if _FS_LOCK3894 #if FF_FS_LOCK != 0 3895 3895 if (res == FR_OK) res = chk_lock(&djo, 2); 3896 3896 #endif … … 3900 3900 } else { 3901 3901 mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about object except name */ 3902 mem_cpy(&djn, &djo, sizeof ( DIR)); /* Duplicate the directory object */3902 mem_cpy(&djn, &djo, sizeof (FATFS_DIR)); /* Duplicate the directory object */ 3903 3903 if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ 3904 3904 res = follow_path(&djn, path_new); /* and make sure if new object name is not conflicting */ … … 3909 3909 dir = djn.dir; 3910 3910 if (dir[DIR_Attr] & AM_DIR) { /* The new object is a directory */ 3911 temp_new_path = (TCHAR *)ff_memalloc(( _MAX_LFN + 1) * sizeof(WCHAR));3912 ntstdio_snprintf(temp_new_path, _MAX_LFN, "%s/%s", path_new, basename((char *)path_old));3911 temp_new_path = (TCHAR *)ff_memalloc((FF_MAX_LFN + 1) * sizeof(WCHAR)); 3912 ntstdio_snprintf(temp_new_path, FF_MAX_LFN, "%s/%s", path_new, basename((char *)path_old)); 3913 3913 res = follow_path(&djn, temp_new_path); 3914 3914 } … … 3966 3966 { 3967 3967 FRESULT res; 3968 DIR dj;3968 FATFS_DIR dj; 3969 3969 BYTE *dir; 3970 3970 DEFINE_NAMEBUF; … … 3977 3977 res = follow_path(&dj, path); /* Follow the file path */ 3978 3978 FREE_BUF(); 3979 if ( _FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))3979 if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT)) 3980 3980 res = FR_INVALID_NAME; 3981 3981 if (res == FR_OK) { … … 3995 3995 } 3996 3996 3997 #endif /* ! _FS_READONLY */3998 #endif /* _FS_MINIMIZE == 0 */3999 #endif /* _FS_MINIMIZE <= 1 */4000 #endif /* _FS_MINIMIZE <= 2 */4001 4002 4003 4004 4005 #if _USE_LABEL3997 #endif /* !FF_FS_READONLY */ 3998 #endif /* FF_FS_MINIMIZE == 0 */ 3999 #endif /* FF_FS_MINIMIZE <= 1 */ 4000 #endif /* FF_FS_MINIMIZE <= 2 */ 4001 4002 4003 4004 4005 #if FF_USE_LABEL 4006 4006 /*-----------------------------------------------------------------------*/ 4007 4007 /* Get volume label */ … … 4015 4015 { 4016 4016 FRESULT res; 4017 DIR dj;4017 FATFS_DIR dj; 4018 4018 UINT i, j; 4019 #if _USE_LFN &&_LFN_UNICODE4019 #if FF_USE_LFN && FF_LFN_UNICODE 4020 4020 WCHAR w; 4021 4021 #endif … … 4032 4032 res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ 4033 4033 if (res == FR_OK) { /* A volume label is exist */ 4034 #if _USE_LFN &&_LFN_UNICODE4034 #if FF_USE_LFN && FF_LFN_UNICODE 4035 4035 i = j = 0; 4036 4036 do { … … 4070 4070 4071 4071 4072 #if ! _FS_READONLY4072 #if !FF_FS_READONLY 4073 4073 /*-----------------------------------------------------------------------*/ 4074 4074 /* Set volume label */ … … 4080 4080 { 4081 4081 FRESULT res; 4082 DIR dj;4082 FATFS_DIR dj; 4083 4083 BYTE vn[11]; 4084 4084 UINT i, j, sl; 4085 4085 WCHAR w; 4086 4086 DWORD tm; 4087 #if _CODE_PAGE == 650014087 #if FF_CODE_PAGE == 65001 4088 4088 int code_size; 4089 char utf8_code[6];4089 unsigned char utf8_code[6]; 4090 4090 #endif 4091 4091 … … 4101 4101 i = j = 0; 4102 4102 do { 4103 #if _CODE_PAGE == 650014103 #if FF_CODE_PAGE == 65001 4104 4104 w = ff_wtoupper(Utf8_to_Utf16(&label[i], &code_size)); 4105 4105 i += code_size; … … 4110 4110 vn[j++] = utf8_code[k]; 4111 4111 #else 4112 #if _USE_LFN &&_LFN_UNICODE4112 #if FF_USE_LFN && FF_LFN_UNICODE 4113 4113 w = ff_convert(ff_wtoupper(label[i++]), 0); 4114 4114 #else … … 4116 4116 if (IsDBCS1(w)) 4117 4117 w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; 4118 #if _USE_LFN4118 #if FF_USE_LFN 4119 4119 w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); 4120 4120 #else … … 4174 4174 } 4175 4175 4176 #endif /* ! _FS_READONLY */4177 #endif /* _USE_LABEL */4176 #endif /* !FF_FS_READONLY */ 4177 #endif /* FF_USE_LABEL */ 4178 4178 4179 4179 … … 4182 4182 /* Forward data to the stream directly (available on only tiny cfg) */ 4183 4183 /*-----------------------------------------------------------------------*/ 4184 #if _USE_FORWARD &&_FS_TINY4184 #if FF_USE_FORWARD && FF_FS_TINY 4185 4185 4186 4186 FRESULT f_forward ( … … 4235 4235 LEAVE_FF(fp->fs, FR_OK); 4236 4236 } 4237 #endif /* _USE_FORWARD */4238 4239 4240 4241 #if _USE_MKFS && !_FS_READONLY4237 #endif /* FF_USE_FORWARD */ 4238 4239 4240 4241 #if FF_USE_MKFS && !FF_FS_READONLY 4242 4242 /*-----------------------------------------------------------------------*/ 4243 4243 /* Create file system on the logical drive */ … … 4263 4263 FATFS *fs; 4264 4264 DSTATUS stat; 4265 #if _USE_TRIM4265 #if FF_USE_TRIM 4266 4266 DWORD eb[2]; 4267 4267 #endif … … 4282 4282 if (stat & STA_NOINIT) return FR_NOT_READY; 4283 4283 if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; 4284 #if _MAX_SS !=_MIN_SS /* Get disk sector size */4285 if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) <_MIN_SS)4284 #if FF_MAX_SS != FF_MIN_SS /* Get disk sector size */ 4285 if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > FF_MAX_SS || SS(fs) < FF_MIN_SS) 4286 4286 return FR_DISK_ERR; 4287 4287 #endif 4288 if ( _MULTI_PARTITION && part) {4288 if (FF_MULTI_PARTITION && part) { 4289 4289 /* Get partition information from partition table in the MBR */ 4290 4290 if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; … … 4308 4308 au = cst[i]; 4309 4309 } 4310 if (au >= _MIN_SS) au /= SS(fs); /* Number of sectors per cluster */4310 if (au >= FF_MIN_SS) au /= SS(fs); /* Number of sectors per cluster */ 4311 4311 if (!au) au = 1; 4312 4312 if (au > 128) au = 128; … … 4362 4362 } 4363 4363 4364 if ( _MULTI_PARTITION && part) {4364 if (FF_MULTI_PARTITION && part) { 4365 4365 /* Update system ID in the partition table */ 4366 4366 tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; … … 4465 4465 } while (--i); 4466 4466 4467 #if _USE_TRIM /* Erase data area if needed */4467 #if FF_USE_TRIM /* Erase data area if needed */ 4468 4468 { 4469 4469 eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; … … 4488 4488 4489 4489 4490 #if _MULTI_PARTITION4490 #if FF_MULTI_PARTITION 4491 4491 /*-----------------------------------------------------------------------*/ 4492 4492 /* Create partition table on the physical drive */ … … 4518 4518 4519 4519 /* Create partition table */ 4520 mem_set(buf, 0, _MAX_SS);4520 mem_set(buf, 0, FF_MAX_SS); 4521 4521 p = buf + MBR_Table; b_cyl = 0; 4522 4522 for (i = 0; i < 4; i++, p += SZ_PTE) { … … 4555 4555 4556 4556 4557 #endif /* _MULTI_PARTITION */4558 #endif /* _USE_MKFS && !_FS_READONLY */4559 4560 4561 4562 4563 #if _USE_STRFUNC4557 #endif /* FF_MULTI_PARTITION */ 4558 #endif /* FF_USE_MKFS && !FF_FS_READONLY */ 4559 4560 4561 4562 4563 #if FF_USE_STRFUNC 4564 4564 /*-----------------------------------------------------------------------*/ 4565 4565 /* Get a string from the file */ … … 4579 4579 4580 4580 while (n < len - 1) { /* Read characters until buffer gets filled */ 4581 #if _USE_LFN &&_LFN_UNICODE4582 #if _STRF_ENCODE == 3 /* Read a character in UTF-8 */4581 #if FF_USE_LFN && FF_LFN_UNICODE 4582 #if FF_STRF_ENCODE == 3 /* Read a character in UTF-8 */ 4583 4583 f_read(fp, s, 1, &rc); 4584 4584 if (rc != 1) break; … … 4602 4602 } 4603 4603 } 4604 #elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */4604 #elif FF_STRF_ENCODE == 2 /* Read a character in UTF-16BE */ 4605 4605 f_read(fp, s, 2, &rc); 4606 4606 if (rc != 2) break; 4607 4607 c = s[1] + (s[0] << 8); 4608 #elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */4608 #elif FF_STRF_ENCODE == 1 /* Read a character in UTF-16LE */ 4609 4609 f_read(fp, s, 2, &rc); 4610 4610 if (rc != 2) break; … … 4627 4627 c = s[0]; 4628 4628 #endif 4629 if ( _USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */4629 if (FF_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ 4630 4630 *p++ = c; 4631 4631 n++; … … 4639 4639 4640 4640 4641 #if ! _FS_READONLY4641 #if !FF_FS_READONLY 4642 4642 #include <stdarg.h> 4643 4643 /*-----------------------------------------------------------------------*/ … … 4662 4662 4663 4663 4664 if ( _USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */4664 if (FF_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ 4665 4665 putc_bfd(pb, '\r'); 4666 4666 … … 4668 4668 if (i < 0) return; 4669 4669 4670 #if _USE_LFN &&_LFN_UNICODE4671 #if _STRF_ENCODE == 3 /* Write a character in UTF-8 */4670 #if FF_USE_LFN && FF_LFN_UNICODE 4671 #if FF_STRF_ENCODE == 3 /* Write a character in UTF-8 */ 4672 4672 if (c < 0x80) { /* 7-bit */ 4673 4673 pb->buf[i++] = (BYTE)c; … … 4681 4681 pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); 4682 4682 } 4683 #elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */4683 #elif FF_STRF_ENCODE == 2 /* Write a character in UTF-16BE */ 4684 4684 pb->buf[i++] = (BYTE)(c >> 8); 4685 4685 pb->buf[i++] = (BYTE)c; 4686 #elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */4686 #elif FF_STRF_ENCODE == 1 /* Write a character in UTF-16LE */ 4687 4687 pb->buf[i++] = (BYTE)c; 4688 4688 pb->buf[i++] = (BYTE)(c >> 8); … … 4871 4871 } 4872 4872 4873 #endif /* ! _FS_READONLY */4874 #endif /* _USE_STRFUNC */4873 #endif /* !FF_FS_READONLY */ 4874 #endif /* FF_USE_STRFUNC */ -
EcnlProtoTool/trunk/ntshell/fatfs/ff.h
r331 r434 28 28 #include "ffconf.h" /* FatFs configuration options */ 29 29 #include "diskio.h" 30 #if _FATFS != _FFCONF30 #if _FATFS != FFCONF_DEF 31 31 #error Wrong configuration file (ffconf.h). 32 32 #endif … … 36 36 /* Definitions of volume management */ 37 37 38 #if _MULTI_PARTITION /* Multiple partition configuration */38 #if FF_MULTI_PARTITION /* Multiple partition configuration */ 39 39 typedef struct { 40 40 BYTE pd; /* Physical drive number */ … … 55 55 /* Type of path name strings on FatFs API */ 56 56 57 #if _LFN_UNICODE /* Unicode string */58 #if ! _USE_LFN59 #error _LFN_UNICODE must be 0 at non-LFN cfg.57 #if FF_LFN_UNICODE /* Unicode string */ 58 #if !FF_USE_LFN 59 #error FF_LFN_UNICODE must be 0 at non-LFN cfg. 60 60 #endif 61 61 #ifndef _INC_TCHAR … … 87 87 WORD id; /* File system mount ID */ 88 88 WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ 89 #if _MAX_SS !=_MIN_SS89 #if FF_MAX_SS != FF_MIN_SS 90 90 WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ 91 91 #endif 92 #if _FS_REENTRANT93 _SYNC_t sobj; /* Identifier of sync object */94 #endif 95 #if ! _FS_READONLY92 #if FF_FS_REENTRANT 93 FF_SYNC_t sobj; /* Identifier of sync object */ 94 #endif 95 #if !FF_FS_READONLY 96 96 DWORD last_clust; /* Last allocated cluster */ 97 97 DWORD free_clust; /* Number of free clusters */ 98 98 #endif 99 #if _FS_RPATH99 #if FF_FS_RPATH 100 100 DWORD cdir; /* Current directory start cluster (0:root) */ 101 101 #endif … … 107 107 DWORD database; /* Data start sector */ 108 108 DWORD winsect; /* Current sector appearing in the win[] */ 109 BYTE win[ _MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */109 BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ 110 110 } FATFS; 111 111 … … 124 124 DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ 125 125 DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ 126 #if ! _FS_READONLY126 #if !FF_FS_READONLY 127 127 DWORD dir_sect; /* Sector number containing the directory entry */ 128 128 BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ 129 129 #endif 130 #if _USE_FASTSEEK130 #if FF_USE_FASTSEEK 131 131 DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ 132 132 #endif 133 #if _FS_LOCK133 #if FF_FS_LOCK != 0 134 134 UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ 135 135 #endif 136 #if ! _FS_TINY137 BYTE buf[ _MAX_SS]; /* File private data read/write window */136 #if !FF_FS_TINY 137 BYTE buf[FF_MAX_SS]; /* File private data read/write window */ 138 138 #endif 139 139 } FIL; … … 141 141 142 142 143 /* Directory object structure ( DIR) */143 /* Directory object structure (FATFS_DIR) */ 144 144 145 145 typedef struct __dirstream { … … 152 152 BYTE* dir; /* Pointer to the current SFN entry in the win[] */ 153 153 BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ 154 #if _FS_LOCK154 #if FF_FS_LOCK != 0 155 155 UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ 156 156 #endif 157 #if _USE_LFN157 #if FF_USE_LFN 158 158 WCHAR* lfn; /* Pointer to the LFN working buffer */ 159 159 WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ 160 160 #endif 161 #if _USE_FIND161 #if FF_USE_FIND 162 162 const TCHAR* pat; /* Pointer to the name matching pattern */ 163 163 #endif 164 } DIR;164 } FATFS_DIR; 165 165 166 166 … … 174 174 BYTE fattrib; /* Attribute */ 175 175 TCHAR fname[13]; /* Short file name (8.3 format) */ 176 #if _USE_LFN176 #if FF_USE_LFN 177 177 TCHAR* lfname; /* Pointer to the LFN buffer */ 178 178 UINT lfsize; /* Size of LFN buffer in TCHAR */ … … 203 203 FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ 204 204 FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ 205 FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */205 FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */ 206 206 FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ 207 207 } FRESULT; … … 220 220 FRESULT f_truncate (FIL* fp); /* Truncate file */ 221 221 FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ 222 FRESULT f_opendir ( DIR* dp, const TCHAR* path); /* Open a directory */223 FRESULT f_closedir ( DIR* dp); /* Close an open directory */224 FRESULT f_readdir ( DIR* dp, FILINFO* fno); /* Read a directory item */225 FRESULT f_findfirst ( DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */226 FRESULT f_findnext ( DIR* dp, FILINFO* fno); /* Find next file */222 FRESULT f_opendir (FATFS_DIR* dp, const TCHAR* path); /* Open a directory */ 223 FRESULT f_closedir (FATFS_DIR* dp); /* Close an open directory */ 224 FRESULT f_readdir (FATFS_DIR* dp, FILINFO* fno); /* Read a directory item */ 225 FRESULT f_findfirst (FATFS_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ 226 FRESULT f_findnext (FATFS_DIR* dp, FILINFO* fno); /* Find next file */ 227 227 FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ 228 228 FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ … … 270 270 271 271 /* RTC function */ 272 #if ! _FS_READONLY && !_FS_NORTC272 #if !FF_FS_READONLY && !FF_FS_NORTC 273 273 DWORD get_fattime (void); 274 274 #endif 275 275 276 276 /* Unicode support functions */ 277 #if _USE_LFN /* Unicode - OEM code conversion */277 #if FF_USE_LFN /* Unicode - OEM code conversion */ 278 278 WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ 279 279 WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ 280 #if _USE_LFN == 3 /* Memory functions */280 #if FF_USE_LFN == 3 /* Memory functions */ 281 281 void* ff_memalloc (UINT msize); /* Allocate memory block */ 282 282 void ff_memfree (void* mblock); /* Free memory block */ … … 285 285 286 286 /* Sync functions */ 287 #if _FS_REENTRANT288 int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */289 int ff_req_grant ( _SYNC_t sobj); /* Lock sync object */290 void ff_rel_grant ( _SYNC_t sobj); /* Unlock sync object */291 int ff_del_syncobj ( _SYNC_t sobj); /* Delete a sync object */287 #if FF_FS_REENTRANT 288 int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */ 289 int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */ 290 void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */ 291 int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */ 292 292 #endif 293 293 … … 304 304 #define FA_OPEN_EXISTING 0x00 305 305 306 #if ! _FS_READONLY306 #if !FF_FS_READONLY 307 307 #define FA_WRITE 0x02 308 308 #define FA_CREATE_NEW 0x04 309 309 #define FA_CREATE_ALWAYS 0x08 310 310 #define FA_OPEN_ALWAYS 0x10 311 #define FA_ _WRITTEN0x20312 #define FA_ _DIRTY 0x40311 #define FA_MODIFIED 0x20 312 #define FA_DIRTY 0x40 313 313 #endif 314 314 … … 341 341 /* Multi-byte word access macros */ 342 342 343 #if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */343 #if FF_WORD_ACCESS == 1 /* Enable word access to the FAT structure */ 344 344 #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) 345 345 #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -
EcnlProtoTool/trunk/ntshell/fatfs/ffarch.c
r424 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2014-201 7Cores Co., Ltd. Japan4 * Copyright (C) 2014-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 279 279 } 280 280 281 int ff_cre_syncobj(BYTE vol, _SYNC_t* sobj)281 int ff_cre_syncobj(BYTE vol, FF_SYNC_t* sobj) 282 282 { 283 283 return 1; 284 284 } 285 285 286 int ff_req_grant( _SYNC_t sobj)286 int ff_req_grant(FF_SYNC_t sobj) 287 287 { 288 288 ER ret; … … 291 291 } 292 292 293 void ff_rel_grant( _SYNC_t sobj)293 void ff_rel_grant(FF_SYNC_t sobj) 294 294 { 295 295 sig_sem(SEM_FILESYSTEM); 296 296 } 297 297 298 int ff_del_syncobj( _SYNC_t sobj)298 int ff_del_syncobj(FF_SYNC_t sobj) 299 299 { 300 300 return 1; -
EcnlProtoTool/trunk/ntshell/fatfs/ffarch.cfg
r321 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2016 Cores Co., Ltd. Japan4 * Copyright (C) 2016-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ -
EcnlProtoTool/trunk/ntshell/fatfs/ffarch.h
r321 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2014-201 6Cores Co., Ltd. Japan4 * Copyright (C) 2014-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 */ 36 36 37 #ifndef _ MRUBY_ARDUINO_H_38 #define _ MRUBY_ARDUINO_H_37 #ifndef _FFARCH_H_ 38 #define _FFARCH_H_ 39 39 40 40 int mruby_arduino_init(); 41 41 void sdfs_cychdr(intptr_t exinf); 42 42 43 #endif /* of #ifndef _ MRUBY_ARDUINO_H_ */43 #endif /* of #ifndef _FFARCH_H_ */ -
EcnlProtoTool/trunk/ntshell/fatfs/ffconf.h
r321 r434 3 3 /---------------------------------------------------------------------------*/ 4 4 5 #define _FFCONF 64180 /* Revision ID */5 #define FFCONF_DEF 64180 /* Revision ID */ 6 6 7 7 /*---------------------------------------------------------------------------/ … … 9 9 /---------------------------------------------------------------------------*/ 10 10 11 #define _FS_READONLY 011 #define FF_FS_READONLY 0 12 12 /* This option switches read-only configuration. (0:Read/Write or 1:Read-only) 13 13 / Read-only configuration removes writing API functions, f_write(), f_sync(), … … 16 16 17 17 18 #define _FS_MINIMIZE 018 #define FF_FS_MINIMIZE 0 19 19 /* This option defines minimization level to remove some basic API functions. 20 20 / … … 26 26 27 27 28 #define _USE_STRFUNC 128 #define FF_USE_STRFUNC 1 29 29 /* This option switches string functions, f_gets(), f_putc(), f_puts() and 30 30 / f_printf(). … … 35 35 36 36 37 #define _USE_FIND 137 #define FF_USE_FIND 1 38 38 /* This option switches filtered directory read feature and related functions, 39 39 / f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */ 40 40 41 41 42 #define _USE_MKFS 142 #define FF_USE_MKFS 1 43 43 /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ 44 44 45 45 46 #define _USE_FASTSEEK 046 #define FF_USE_FASTSEEK 0 47 47 /* This option switches fast seek feature. (0:Disable or 1:Enable) */ 48 48 49 49 50 #define _USE_LABEL 150 #define FF_USE_LABEL 1 51 51 /* This option switches volume label functions, f_getlabel() and f_setlabel(). 52 52 / (0:Disable or 1:Enable) */ 53 53 54 54 55 #define _USE_FORWARD 155 #define FF_USE_FORWARD 1 56 56 /* This option switches f_forward() function. (0:Disable or 1:Enable) 57 / To enable it, also _FS_TINY need to be set to 1. */57 / To enable it, also FF_FS_TINY need to be set to 1. */ 58 58 59 59 … … 62 62 /---------------------------------------------------------------------------*/ 63 63 64 #define _CODE_PAGE 6500164 #define FF_CODE_PAGE 65001 65 65 /* This option specifies the OEM code page to be used on the target system. 66 66 / Incorrect setting of the code page can cause a file open failure. … … 91 91 92 92 93 #define _USE_LFN 394 #define _MAX_LFN 25595 /* The _USE_LFN option switches the LFN feature.96 / 97 / 0: Disable LFN feature. _MAX_LFN has no effect.93 #define FF_USE_LFN 3 94 #define FF_MAX_LFN 255 95 /* The FF_USE_LFN option switches the LFN feature. 96 / 97 / 0: Disable LFN feature. FF_MAX_LFN has no effect. 98 98 / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. 99 99 / 2: Enable LFN with dynamic working buffer on the STACK. … … 101 101 / 102 102 / When enable the LFN feature, Unicode handling functions (option/unicode.c) must 103 / be added to the project. The LFN working buffer occupies ( _MAX_LFN + 1) * 2 bytes.103 / be added to the project. The LFN working buffer occupies (FF_MAX_LFN + 1) * 2 bytes. 104 104 / When use stack for the working buffer, take care on stack overflow. When use heap 105 105 / memory for the working buffer, memory management functions, ff_memalloc() and … … 107 107 108 108 109 #define _LFN_UNICODE 0109 #define FF_LFN_UNICODE 0 110 110 /* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode) 111 / To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE111 / To use Unicode string for the path name, enable LFN feature and set FF_LFN_UNICODE 112 112 / to 1. This option also affects behavior of string I/O functions. */ 113 113 114 114 115 #define _STRF_ENCODE 3116 /* When _LFN_UNICODE is 1, this option selects the character encoding on the file to115 #define FF_STRF_ENCODE 3 116 /* When FF_LFN_UNICODE is 1, this option selects the character encoding on the file to 117 117 / be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf(). 118 118 / … … 122 122 / 3: UTF-8 123 123 / 124 / When _LFN_UNICODE is 0, this option has no effect. */125 126 127 #define _FS_RPATH 2124 / When FF_LFN_UNICODE is 0, this option has no effect. */ 125 126 127 #define FF_FS_RPATH 2 128 128 /* This option configures relative path feature. 129 129 / … … 139 139 /---------------------------------------------------------------------------*/ 140 140 141 #define _VOLUMES 2141 #define FF_VOLUMES 2 142 142 /* Number of volumes (logical drives) to be used. */ 143 143 144 144 145 #define _STR_VOLUME_ID 0146 #define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"147 /* _STR_VOLUME_ID option switches string volume ID feature.148 / When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive149 / number in the path name. _VOLUME_STRS defines the drive ID strings for each150 / logical drives. Number of items must be equal to _VOLUMES. Valid characters for145 #define FF_STR_VOLUME_ID 0 146 #define FF_VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3" 147 /* FF_STR_VOLUME_ID option switches string volume ID feature. 148 / When FF_STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive 149 / number in the path name. FF_VOLUME_STRS defines the drive ID strings for each 150 / logical drives. Number of items must be equal to FF_VOLUMES. Valid characters for 151 151 / the drive ID strings are: A-Z and 0-9. */ 152 152 153 153 154 #define _MULTI_PARTITION 0154 #define FF_MULTI_PARTITION 0 155 155 /* This option switches multi-partition feature. By default (0), each logical drive 156 156 / number is bound to the same physical drive number and only an FAT volume found on … … 160 160 161 161 162 #define _MIN_SS 512163 #define _MAX_SS 512162 #define FF_MIN_SS 512 163 #define FF_MAX_SS 512 164 164 /* These options configure the range of sector size to be supported. (512, 1024, 165 165 / 2048 or 4096) Always set both 512 for most systems, all type of memory cards and 166 166 / harddisk. But a larger value may be required for on-board flash memory and some 167 / type of optical media. When _MAX_SS is larger than_MIN_SS, FatFs is configured167 / type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured 168 168 / to variable sector size and GET_SECTOR_SIZE command must be implemented to the 169 169 / disk_ioctl() function. */ 170 170 171 171 172 #define _USE_TRIM 0172 #define FF_USE_TRIM 0 173 173 /* This option switches ATA-TRIM feature. (0:Disable or 1:Enable) 174 174 / To enable Trim feature, also CTRL_TRIM command should be implemented to the … … 176 176 177 177 178 #define _FS_NOFSINFO 0178 #define FF_FS_NOFSINFO 0 179 179 /* If you need to know correct free space on the FAT32 volume, set bit 0 of this 180 180 / option, and f_getfree() function at first time after volume mount will force … … 193 193 /---------------------------------------------------------------------------*/ 194 194 195 #define _FS_TINY 1195 #define FF_FS_TINY 1 196 196 /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) 197 / At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS197 / At the tiny configuration, size of the file object (FIL) is reduced FF_MAX_SS 198 198 / bytes. Instead of private sector buffer eliminated from the file object, 199 199 / common sector buffer in the file system object (FATFS) is used for the file … … 201 201 202 202 203 #define _FS_NORTC 0204 #define _NORTC_MON 1205 #define _NORTC_MDAY 1206 #define _NORTC_YEAR 2015207 /* The _FS_NORTC option switches timestamp feature. If the system does not have208 / an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable203 #define FF_FS_NORTC 0 204 #define FF_NORTC_MON 1 205 #define FF_NORTC_MDAY 1 206 #define FF_NORTC_YEAR 2015 207 /* The FF_FS_NORTC option switches timestamp feature. If the system does not have 208 / an RTC function or valid timestamp is not needed, set FF_FS_NORTC to 1 to disable 209 209 / the timestamp feature. All objects modified by FatFs will have a fixed timestamp 210 / defined by _NORTC_MON, _NORTC_MDAY and_NORTC_YEAR.211 / When timestamp feature is enabled ( _FS_NORTC == 0), get_fattime() function need212 / to be added to the project to read current time form RTC. _NORTC_MON,213 / _NORTC_MDAY and_NORTC_YEAR have no effect.214 / These options have no effect at read-only configuration ( _FS_READONLY == 1). */215 216 217 #define _FS_LOCK 0218 /* The _FS_LOCK option switches file lock feature to control duplicated file open219 / and illegal operation to open objects. This option must be 0 when _FS_READONLY210 / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR. 211 / When timestamp feature is enabled (FF_FS_NORTC == 0), get_fattime() function need 212 / to be added to the project to read current time form RTC. FF_NORTC_MON, 213 / FF_NORTC_MDAY and FF_NORTC_YEAR have no effect. 214 / These options have no effect at read-only configuration (FF_FS_READONLY == 1). */ 215 216 217 #define FF_FS_LOCK 0 218 /* The FF_FS_LOCK option switches file lock feature to control duplicated file open 219 / and illegal operation to open objects. This option must be 0 when FF_FS_READONLY 220 220 / is 1. 221 221 / … … 227 227 228 228 229 #define _FS_REENTRANT 1230 #define _FS_TIMEOUT 1000231 #define _SYNC_t unsigned int232 /* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs229 #define FF_FS_REENTRANT 1 230 #define FF_FS_TIMEOUT 1000 231 #define FF_SYNC_t unsigned int 232 /* The FF_FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs 233 233 / module itself. Note that regardless of this option, file access to different 234 234 / volume is always re-entrant and volume control functions, f_mount(), f_mkfs() … … 236 236 / to the same volume is under control of this feature. 237 237 / 238 / 0: Disable re-entrancy. _FS_TIMEOUT and_SYNC_t have no effect.238 / 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect. 239 239 / 1: Enable re-entrancy. Also user provided synchronization handlers, 240 240 / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() … … 242 242 / option/syscall.c. 243 243 / 244 / The _FS_TIMEOUT defines timeout period in unit of time tick.245 / The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,244 / The FF_FS_TIMEOUT defines timeout period in unit of time tick. 245 / The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, 246 246 / SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be 247 247 / included somewhere in the scope of ff.c. */ 248 248 249 249 250 #define _WORD_ACCESS 1251 /* The _WORD_ACCESS option is an only platform dependent option. It defines250 #define FF_WORD_ACCESS 1 251 /* The FF_WORD_ACCESS option is an only platform dependent option. It defines 252 252 / which access method is used to the word data on the FAT volume. 253 253 / … … 258 258 / * Byte order on the memory is little-endian. 259 259 / 260 / If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.260 / If it is the case, FF_WORD_ACCESS can also be set to 1 to reduce code size. 261 261 / Following table shows allowable settings of some type of processors. 262 262 / -
EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c
r433 r434 249 249 char *fn; 250 250 251 #if _USE_LFN251 #if FF_USE_LFN 252 252 fn = *fno->lfname ? fno->lfname : fno->fname; 253 253 #else … … 289 289 } 290 290 291 #define LFN_BUF_SIZE ( _MAX_LFN + 1)291 #define LFN_BUF_SIZE (FF_MAX_LFN + 1) 292 292 /* lsコマンド dir内 表示 */ 293 293 void print_ls(char *path_p, char *pattern_p, BYTE list_option) … … 295 295 FRESULT res; 296 296 FILINFO fno; 297 DIR dir;297 FATFS_DIR dir; 298 298 char *fn; /* This function assumes non-Unicode configuration */ 299 299 … … 308 308 } 309 309 310 #if _USE_LFN310 #if FF_USE_LFN 311 311 char *lfn = NULL; 312 312 lfn = ff_memalloc(LFN_BUF_SIZE); … … 330 330 331 331 while ((res == FR_OK) && (fno.fname[0] != 0)) { 332 if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* DIR とパターンマッチしている場合はDIR 内部を ls する */333 #if _USE_LFN332 if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* FATFS_DIR とパターンマッチしている場合は FATFS_DIR 内部を ls する */ 333 #if FF_USE_LFN 334 334 fn = *fno.lfname ? fno.lfname : fno.fname; 335 335 #else … … 381 381 { 382 382 char *pattern_p = NULL, *basename_p = NULL, *dirname_p = NULL; 383 char default_pattern[ _MAX_LFN] = "";383 char default_pattern[FF_MAX_LFN] = ""; 384 384 int c; 385 385 BYTE list_option = 0; … … 443 443 return 0; 444 444 445 #if _USE_LFN445 #if FF_USE_LFN 446 446 /* LFN buffer alloc */ 447 447 lfn = ff_memalloc(LFN_BUF_SIZE); -
EcnlProtoTool/trunk/ntshell/src/fdtable.c
r433 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2017 Cores Co., Ltd. Japan4 * Copyright (C) 2017-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ -
EcnlProtoTool/trunk/ntshell/src/fdtable.h
r433 r434 119 119 FIL file; 120 120 struct { 121 DIR dir;121 FATFS_DIR dir; 122 122 struct dirent dirent; 123 123 }; -
EcnlProtoTool/trunk/ntshell/src/io_stub.c
r433 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2017 Cores Co., Ltd. Japan4 * Copyright (C) 2017-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 100 100 return -ENOMEM; 101 101 102 DIR *dir = &fp->dir;102 FATFS_DIR *dir = &fp->dir; 103 103 FRESULT res; 104 104 if ((res = f_opendir(dir, path)) != FR_OK) { … … 405 405 FILINFO fi; 406 406 FRESULT ret; 407 #if _USE_LFN408 static char lfn[ _MAX_LFN + 1]; /* Buffer to store the LFN */407 #if FF_USE_LFN 408 static char lfn[FF_MAX_LFN + 1]; /* Buffer to store the LFN */ 409 409 fi.lfname = lfn; 410 410 fi.lfsize = sizeof lfn; 411 411 #endif 412 412 if (ntlibc_strcmp(path, ".") == 0) { 413 char cwd[ _MAX_LFN];413 char cwd[FF_MAX_LFN]; 414 414 if ((ret = f_getcwd(cwd, sizeof(cwd))) != FR_OK) { 415 415 return fresult2errno(ret); … … 578 578 579 579 FILINFO fno; 580 #if _USE_LFN581 static char lfn[ _MAX_LFN + 1]; /* Buffer to store the LFN */580 #if FF_USE_LFN 581 static char lfn[FF_MAX_LFN + 1]; /* Buffer to store the LFN */ 582 582 fno.lfname = lfn; 583 583 fno.lfsize = sizeof lfn; … … 589 589 590 590 memset(de, 0, sizeof(*de)); 591 #if _USE_LFN591 #if FF_USE_LFN 592 592 ntlibc_strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name)); 593 593 #else … … 622 622 else { 623 623 FILINFO fno; 624 #if _USE_LFN625 static char lfn[ _MAX_LFN + 1]; /* Buffer to store the LFN */624 #if FF_USE_LFN 625 static char lfn[FF_MAX_LFN + 1]; /* Buffer to store the LFN */ 626 626 fno.lfname = lfn; 627 627 fno.lfsize = sizeof lfn; -
EcnlProtoTool/trunk/ntshell/src/main.c
r433 r434 185 185 { 186 186 FILINFO fno; 187 #if _USE_LFN188 char lfn[ _MAX_LFN + 1];187 #if FF_USE_LFN 188 char lfn[FF_MAX_LFN + 1]; 189 189 fno.lfname = lfn; 190 fno.lfsize = _MAX_LFN + 1;190 fno.lfsize = FF_MAX_LFN + 1; 191 191 #endif 192 192 ER ret; -
EcnlProtoTool/trunk/ntshell/src/main.cfg
r431 r434 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2014-201 6Cores Co., Ltd. Japan4 * Copyright (C) 2014-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 37 37 38 38 /* 39 * サンプルプログラム(1)のシステムコンフィギュレーションファイル39 * ntshellのシステムコンフィギュレーションファイル 40 40 */ 41 41 #include "main.h" -
EcnlProtoTool/trunk/ntshell/src/shellif.h
r331 r434 111 111 112 112 // dirent.h 113 typedef struct __dirstream DIR;113 typedef struct __dirstream FATFS_DIR; 114 114 115 115 int shell_getdents(int, struct dirent *, size_t); -
EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c
r331 r434 69 69 FRESULT res; 70 70 FILINFO fno; 71 DIR dir;71 FATFS_DIR dir; 72 72 int i; 73 73 char *fn; /* This function assumes non-Unicode configuration */ … … 102 102 FIL *fd = (FIL *)&file->fd; 103 103 FILINFO fno; 104 DIR dir;104 FATFS_DIR dir; 105 105 106 106 file->pos = 0;
Note:
See TracChangeset
for help on using the changeset viewer.