实现代码:
static void mmi_camera_get_next_filename(PS8 file_buf_p)
{
#ifdef __BTL_MOD__
MYTIME time;
char filename[128];
GetDateTime(&time);
if(g_btl_log_ctx.camera_snap.warn_num == 0)
{
kal_wsprintf((WCHAR *)file_buf_p , "D://Photos//Usual_pic//IMG%d%02d%02d%02d%02d%02d.jpg",
time.nYear , time.nMonth,time.nDay , time.nHour , time.nMin , time.nSec);
pfnUnicodeStrcpy((S8*)g_btl_log_ctx.get_usual_name.name , (S8*)file_buf_p);
}
else
{
kal_wsprintf((WCHAR *)file_buf_p , "D://Photos//Warn_pic//IMG%d%02d%02d%02d%02d%02d.jpg",
time.nYear, time.nMonth, time.nDay, time.nHour, time.nMin, time.nSec);
pfnUnicodeStrcpy((S8*)g_btl_log_ctx.get_warning_name.name , (S8*)file_buf_p);
}
pfnUnicodeStrcpy((S8*)g_btl_log_ctx.get_usual_name.name , (S8*)file_buf_p);
dt_ucs2_to_ascii((WCHAR *)file_buf_p , (WCHAR *)filename);
kal_prompt_trace(MOD_MMI , "get_next_filename: %s" , filename);
#else
S8 buffer[25];
S8 UCS2_buffer[50];
S8 UCS2_testname[50];
S8 UCS2_alpha[10];
S16 error = 0;
U16 filename_seq_no;
U16 alpha_count;
U16 alpha_index;
FS_HANDLE file_handle;
U16 file_check = 0;
ReadValue(NVRAM_CAM_FILENAME_SEQ_NO, &filename_seq_no, DS_SHORT, &error);
if (filename_seq_no == 0xffff)
{
filename_seq_no = 1;
}
else
{
filename_seq_no++;
if (filename_seq_no > 9999)
{
filename_seq_no = 1;
}
}
alpha_count = 'Z' - 'A' + 1;
alpha_index = 0;
sprintf((PS8) buffer, "IMG%04d", filename_seq_no);
AnsiiToUnicodeString((PS8) UCS2_buffer, (PS8) buffer);
while (1)
{
sprintf((PS8) buffer, "%c", 'A' + alpha_index);
AnsiiToUnicodeString((PS8) UCS2_alpha, (PS8) buffer);
UCS2Strcpy(UCS2_testname, UCS2_buffer);
UCS2Strcat(UCS2_testname, UCS2_alpha);
UCS2Strcat(UCS2_testname, (PS8) L".jpg");
UCS2Strcpy((PS8) file_buf_p, (PS8) g_camera_cntx.storage_filepath);
UCS2Strcat((PS8) file_buf_p, (PS8) UCS2_testname);
file_handle = FS_Open((U16*) file_buf_p, FS_READ_ONLY);
if (file_handle >= 0)
{
FS_Close(file_handle);
alpha_index++;
}
else
{
WriteValue(NVRAM_CAM_FILENAME_SEQ_NO, &filename_seq_no, DS_SHORT, &error);
return;
}
if (alpha_index >= alpha_count )
{
alpha_count = 'Z' - 'A' + 1;
alpha_index = 0;
filename_seq_no++;
file_check++;
if (filename_seq_no > 9999)
{
filename_seq_no = 1;
}
sprintf((PS8) buffer, "IMG%04d", filename_seq_no);
AnsiiToUnicodeString((PS8) UCS2_buffer, (PS8) buffer);
if (file_check >= 9999)
return;
}
}
#endif
}