现在是打开SD文件夹都正常,但是当进入函数f_readdir中时,出现死机现象,在使能了长文件名和中文支持的情况下(_USE_LFN=3,_CODE_PAGE=936),当把get_fileinfo函数中的这段代码屏蔽掉时能读取文件名,但是读不出来常文件名,函数是在主函数中调用的,在主函数中申明了FILINFO Tempfile,和 DIR Tempfile,结构体成员Tempfile.fsize被赋的值为Tempfile.fsize=_MAX_LFN*2+1,但当结构体参数传入函数f_readdir函数中时结构体的成员Tempfile.fsize被清零了,是结构体被定义到主函数内部的原因吗,求大神帮忙解决
#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2
static
void get_fileinfo ( /* No return code */
DIR* dp, /* Pointer to the directory object */
FILINFO* fno /* Pointer to the file information to be filled */
)
{
UINT i;
TCHAR *p, c;
p = fno->fname;
if (dp->sect) { /* Get SFN */
BYTE *dir = dp->dir;
i = 0;
while (i < 11) { /* Copy name body and extension */
c = (TCHAR)dir[i++];
if (c == ' ') continue; /* Skip padding spaces */
if (c == NDDE) c = (TCHAR)DDE; /* Restore replaced DDE character */
if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */
#if _USE_LFN
if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY)))
c += 0x20; /* To lower */
#if _LFN_UNICODE
if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i]))
c = c << 8 | dir[i++];
c = ff_convert(c, 1); /* OEM -> Unicode */
if (!c) c = '?';
#endif
#endif
*p++ = c;
}
fno->fattrib = dir[DIR_Attr]; /* Attribute */
fno->fsize = LD_DWORD(dir+DIR_FileSize); /* Size */
fno->fdate = LD_WORD(dir+DIR_WrtDate); /* Date */
fno->ftime = LD_WORD(dir+DIR_WrtTime); /* Time */
}
*p = 0; /* Terminate SFN string by a */
//#if _USE_LFN
// if (fno->lfname) {
// WCHAR w, *lfn;
// i = 0; p = fno->lfname;
// if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */
// lfn = dp->lfn;
// while ((w = *lfn++) != 0) { /* Get an LFN character */
//#if !_LFN_UNICODE
// w = ff_convert(w, 0); /* Unicode -> OEM */
// if (!w) { i = 0; break; } /* No LFN if it could not be converted */
// if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */
// p[i++] = (TCHAR)(w >> 8);
//#endif
// if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */
// p[i++] = (TCHAR)w;
// }
// }
// p[i] = 0; /* Terminate LFN string by a */
// }
//#endif
}
#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2*/
一周热门 更多>