关于全志V3文件命名问题

来源:互联网 发布:淘宝如何查看收藏宝贝 编辑:程序博客网 时间:2024/06/06 11:00

这年头什么奇葩需求都有,这不好好地文件是年月日时分秒组成的,他偏要文件个数计数!!!

需求:3. 视频文件名称:KB0001,后4位数值随文件个数递增4. 照片文件名称:K0000001,后7位数值随文件个数递

错误方式

  //我脑海闪过的第一概念,就是改命名就可以了。  //于是我就这样操作了一波将文件命名直接计数  #if 0    sprintf(buf, "%s%04d%02d%02d_%02d%02d%02d%s%s%s",path,tm->tm_year + 1900, tm->tm_mon + 1,        tm->tm_mday, tm->tm_hour,tm->tm_min, tm->tm_sec, camType, suffix, fileType);    #else    if(strncmp(fileType,EXT_PIC_JPG,4) == 0)        {            //sscanf(buf, "%[0-9]4d%[0-9]3d",picture_num_there , picture_num_four);              //db_msg("%s",buf);            db_msg("--EXT_PIC_JPG-%d----%d",picture_num_there, picture_num_four);            picture_num_four++;            if(picture_num_four >9999){                    picture_num_four=0;                    picture_num_there++;                        if(picture_num_there >999){                            picture_num_there=0;                            }            }            sprintf(buf, "%sK%04d%03d%s%s",path, picture_num_there, picture_num_four,suffix, fileType);        }    else        {                picture_num_four++;                        if(picture_num_four >9999){                            picture_num_four=0;                            }            sprintf(buf, "%sKB%04d%s%s",path, video_num_four,suffix, fileType);         }    #endif
//命名之后,由于机器掉电,不管是栈还是堆,数据都会丢失,除非是保存在文件中。。。//但是我脑海想到是开始去获取文件名,(文件是DBCtrl做的数据包装),我直接获取是上次拍照的最后一张,这样照片排序的问题就解决了(那是我考虑得太简单)//我把获取文件信息函数加到开机函数构造哪里,并加了几句代码    strcpy(buf,dbRecord.file);    sscanf(buf, "/mnt/extsd/photo/K%[^.].jpg",tmp2);    sscanf(tmp2, "%3d%4d",&mSTM->picture_num_four,&mSTM->picture_num_there);    db_msg("buf=%s ,tmp1=%s,tmp2=%s",buf,tmp1,tmp2);    db_msg("--EXT_PIC_JPG-%d----%d",mSTM->picture_num_four, mSTM->picture_num_there);

正确处理方式

//我想到视频又要出处理,而且如果SD卡中有其他不是本机拍的照片那我写的函数不就有问题了吗//赶紧的计数信息保存到文件中//不知道为什么全志的menu.cfg增加信息里面的(unsigned int)count,current大于99突然就会报这种错误,缓冲区溢出的错误,然后就死机。V/ResourceManager.cpp(   61): <line[4173] syncConfigureToDisk()> buf is 4Fbc    (   61): *** vsprintf buffer overflow detected ***Fbc    (   61): Fatal signal 6 (SIGABRT) at 0x0000003d (code=0), thread 61 (sdv)I/DEBUG   (   59): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***I/DEBUG   (   59): Build fingerprint: 'softwinners/crane_sl609/crane-sl609:4.2.2/JDQ39/eng.quhongbo.20161230.091807:eng/test-keys'I/DEBUG   (   59): Revision: '0'I/DEBUG   (   59): pid: 61, tid: 61, name: sdv  >>> /system/bin/sdv <<<I/DEBUG   (   59): signal 6 (SIGABRT), code -6 (?), fault addr --------//但也难不住我,我把它分开保存就是
+//1首先在菜单中建立信息+#########################+#文件信息保存+#+########################+[picturefilename_info]+current=0+count=0++[videofilename_info]+current=0+count=0
//2信息列表以及相关资源设置//+#define CFG_MENU_PICTUREFILENAME       "picturefilename_info" //add by popo+#define CFG_MENU_VIDEOFILENAME         "videofilename_info" //add by popo+       {CFG_MENU_PICTUREFILENAME, (void*)&rMenuList.menuDataPictureName}, //add by popo+       {CFG_MENU_VIDEOFILENAME, (void*)&rMenuList.menuDataVideoName}, //add by popo+   ID_MENU_LIST_PICTURE_NAME,  //ADD BY popo+   ID_MENU_LIST_PICTURE_INFO,  //ADD BY popo+   ID_MENU_LIST_VIDEO_NAME,+   ID_MENU_LIST_VIDEO_INFO,
文件命名获取    tmp1 =rm->getSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_NAME);    tmp2=rm->getSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_INFO);    picture_num_four=tmp2*100+tmp1;    tmp1 =rm->getSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_NAME);    tmp2=rm->getSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_INFO);    video_num_four=tmp2*100+tmp1;    #if 0    sprintf(buf, "%s%04d%02d%02d_%02d%02d%02d%s%s%s",path,tm->tm_year + 1900, tm->tm_mon + 1,        tm->tm_mday, tm->tm_hour,tm->tm_min, tm->tm_sec, camType, suffix, fileType);    #else    if(strncmp(fileType,EXT_PIC_JPG,4) == 0)        {            sscanf(buf, "%[0-9]4d%[0-9]3d",picture_num_there , picture_num_four);              db_msg("%s",buf);            db_msg("--EXT_PIC_JPG-%d----%d",picture_num_there, picture_num_four);            picture_num_four++;            if(picture_num_four >9999){                    picture_num_four=0;                    picture_num_there++;                        if(picture_num_there >999){                            picture_num_there=0;                            }            }            sprintf(buf, "%sK%04d%03d%s%s",path, picture_num_there, picture_num_four,suffix, fileType);            rm->setSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_NAME,picture_num_four);         }    else        {                        video_num_four++;                        if(video_num_four >9999){                            video_num_four=0;                            }            sprintf(buf, "%sKB%04d%s%s",path, video_num_four,suffix, fileType);             rm->setSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_NAME,video_num_four);         }    #endif
//获取和处理+   case ID_MENU_LIST_PICTURE_NAME:  //add by popo+       index = rMenuList.menuDataPictureName.current;+       break;  +   case ID_MENU_LIST_PICTURE_INFO:  //add by popo+       index = rMenuList.menuDataPictureName.count;+       break;  +   case ID_MENU_LIST_VIDEO_NAME:  //add by popo+       index = rMenuList.menuDataVideoName.current;+       break;  +   case ID_MENU_LIST_VIDEO_INFO:  //add by popo+       index = rMenuList.menuDataVideoName.count;+       break;+   case ID_MENU_LIST_PICTURE_NAME:+       int tmp1,tmp2;+       tmp1 =newSel/100;+       tmp2 =newSel%100;+       rMenuList.menuDataPictureName.count = tmp1;+       rMenuList.menuDataPictureName.current = tmp2;+   //  SendMessage(mHwnd[WINDOWID_RECORDPREVIEW], MSG_RM_PICTURE_NAME, (WPARAM)newSel, 0);+       break;  +   case ID_MENU_LIST_VIDEO_NAME:+       int tmp3,tmp4;+       tmp3 =newSel/100;+       tmp4 =newSel%100;+       rMenuList.menuDataVideoName.count = tmp3;+       rMenuList.menuDataVideoName.current = tmp4;+   //  SendMessage(mHwnd[WINDOWID_RECORDPREVIEW], MSG_RM_PICTURE_NAME, (WPARAM)newSel, 0);+       break;  +   tmp1 =rm->getSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_NAME);+   tmp2=rm->getSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_INFO);+   picture_num_four=tmp2*100+tmp1;++   tmp1 =rm->getSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_NAME);+   tmp2=rm->getSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_INFO);+   video_num_four=tmp2*100+tmp1;//格式化清零+   rm->setSubMenuCurrentIndex(ID_MENU_LIST_PICTURE_NAME,0);    +   rm->setSubMenuCurrentIndex(ID_MENU_LIST_VIDEO_NAME,0);  +
//信息保存++@@ -4129,6 +4144,8 @@ void ResourceManager::syncConfigureToDisk(void)++      {CFG_MENU_PHOTO_TIMETAKEPHOTOS,          (void*)&rMenuList.menuDataPhotoTimeTakePhotos},++      {CFG_MENU_PHOTO_AUTOMATICTAKEPHOTOS,    (void*)&rMenuList.menuDataPhotoAutomaticTakePhotos},++      {CFG_MENU_PHOTO_MOTIONTAKEPHOTOS,      (void*)&rMenuList.menuDataPhotoMotionTakePhotos},+++     {CFG_MENU_PICTUREFILENAME,     (void*)&rMenuList.menuDataPictureName},
/*总结,拿到问题,要考虑它的全面性,而不是简单直译。//这个按道理我还要进行删除的减法,以及删除后重新排序问题。但是时间催紧,以及自身能力的问题,这个问题只能待优化了。
0 0
原创粉丝点击