- C/C++ code
void SetName(belle *pMe){ char time[50]; char temGroup[10]; char temGroup1[10]; char temGroup2[10]; char temGroup3[10]; char temGroup4[10]; char temGroup5[10]; JulianType rJulianDate; GETJULIANDATE(0, &rJulianDate); DBGPRINTF("wYear=%d,wMonth=%d,wDay=%d,wHour=%d,wMinute=%d,wSecond=%d\n",rJulianDate.wYear,rJulianDate.wMonth,rJulianDate.wDay,rJulianDate.wHour,rJulianDate.wMinute,rJulianDate.wSecond); SPRINTF((char*)temGroup, "%d", rJulianDate.wYear); SPRINTF((char*)temGroup1, "%d", rJulianDate.wMonth); SPRINTF((char*)temGroup2, "%d", rJulianDate.wDay); SPRINTF((char*)temGroup3, "%d", rJulianDate.wHour); SPRINTF((char*)temGroup4, "%d", rJulianDate.wMinute); SPRINTF((char*)temGroup5, "%d", rJulianDate.wSecond); DBGPRINTF("%s-%s-%s-%s:%s:%s",temGroup,temGroup1,temGroup2,temGroup3,temGroup4,temGroup5); MEMSET(time,0,sizeof(time)); STRCAT((char*)time,temGroup); STRCAT((char*)time,temGroup1); STRCAT((char*)time,temGroup2); STRCAT((char*)time,temGroup3); STRCAT((char*)time,temGroup4); STRCAT((char*)time,temGroup5); DBGPRINTF("=================%s",time); MEMSET(pMe->savefilename,0,sizeof(pMe->savefilename));STRCAT(pMe->savefilename,"fs:/mod/10888/");STRCAT(pMe->savefilename,time);STRCAT(pMe->savefilename,".jpg");}void ReadFile(belle *pMe,const char *myfile,const char *savefile){ int count; AEEFileInfo pInfo; AECHAR sh[20] ={'l','i','n','g'}; AECHAR ss[20] ={'s','s','s','s'}; pMe->pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,myfile,_OFM_READ); if(pMe->pMyFile==NULL){ DBGPRINTF("ENTER pMe->pMyFile11 = NULL\n"); return; } IFILE_GetInfo(pMe->pMyFile,&pInfo);//读取文件大小 DBGPRINTF("pMe->pInfo->dwSize=%d\n",pInfo.dwSize); pMe->mydata=(char *)MALLOC(pInfo.dwSize);//分配动态内存 if(pMe->mydata==NULL){ DBGPRINTF("mydata FAKL\n"); } IFILE_Read(pMe->pMyFile,(void *)pMe->mydata,pInfo.dwSize); IFILE_Release(pMe->pMyFile); pMe->pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,savefile,_OFM_READWRITE); if(pMe->pMyFile==NULL){ //pMe->pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,"fs:/mod/10888/myfile.jpg",_OFM_CREATE); pMe->pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,savefile,_OFM_CREATE);if(pMe->pMyFile ==NULL){ IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_NORMAL,ss,-1,20,60,NULL,IDF_ALIGN_CENTER); return; } } count = IFILE_Write(pMe->pMyFile,(void *)pMe->mydata,pInfo.dwSize); if(0 == count) { IDISPLAY_DrawText(pMe->a.m_pIDisplay,AEE_FONT_NORMAL,sh,-1,20,20,NULL,IDF_ALIGN_CENTER); } IFILE_Release(pMe->pMyFile); FREE(pMe->mydata);}
这是那个写文件的函数和设置文件的名字。
在模拟器上运行完全正常,但是到了手机上保存图片就找不到了。
这里我还做了再手机上的测试输出创建文件失败或者写入失败会在屏幕上打印出来字母,但是在机器上测试都没有打印出来。说明创建成功了,但是我在AppLoader里面找不到。这是为什么? 是不是需要设置什么?
------解决方案--------------------------------------------------------
目录不能使用"fs:/mod/10888/",应该用 "fs:/~0x0102382c/"或者用其宏
AEEFS_MCF_PICTURE_DIR,这是brew文件访问安全所有求的。
如果你想写AEEFS_MCF_PICTURE_LOCK_DIR目录,还要在MIF文件中dependency中加相应项。
进一步参见AEEMCF.h
------解决方案--------------------------------------------------------
1. 首先修改输出目录"fs:/shared/",验证一下你的程序是否在手机上运行正确。
2. 试一试在mif文件中的dependencies中选择MCF_PICTURE 和MCF_PICTURE_LOCK添加到右边