INT32 drv_update_app_flash_file ( UINT8 *pucFileBuf, UINT32 ulFileLen, char *szTFFSFileName )
{
char szTargetFile[ FILE_NAME_LENGTH ]; /* 写入到TFFS文件系统中的文件名 */
FILE *fd; /* 文件描述符 */
UINT32 ulCount = 0;
UINT32 i = 0;
INT8 ret = 2;
printf("Write file: %23s %7dByte..................................................", szTFFSFileName, ulFileLen);
if ( tffsDrv () != OK )
{
printf ("[Could not initialize]\n");
return (ERROR);
}
dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-FS */
/* 配置初始化TFFS */
usrTffsConfig ( 0, 0, "/tffs" );
/* 组合文件名/tffs/.. */
strcpy ( szTargetFile, "/tffs" );
strcat ( szTargetFile, "/");
strcat ( szTargetFile, szTFFSFileName);
if( ( fd = fopen( (char *)szTargetFile, "wb+" ) ) == NULL )
{
printf("[DRV]ERROR: cannot open file");
return -1;
}
ulCount = (ulFileLen+512-1)/512;
for(i = 0; i<ulCount; i++)
{
ret = fwrite((void *)( pucFileBuf+i*512 ), 512, 1, fd );
if( ret != 1 )
{
printf("[ERROR]: file write error \n");
return -1;
}
if((i % 32 ) == 0 )
{
printf("\b\b\b\b%3d%%",i*100/ulCount);
}
}
printf("\b\b\b\b%3d%%",i*100/ulCount);
fclose(fd);
printf("[completed]\n");
return (OK);
}
------解决方案--------------------------------------------------------
顶一下,楼上的帖子很纠结,共同学习中!