MTK文件操作时候出现问题,求高手解答!急!!!
void extBook_gen_booklist_file(void)
{
int hFile;
FS_DOSDirEntry file_info;
unsigned short *full_path = NULL, *target_path = NULL;
unsigned short *file_name = NULL;
extBook_scan_book_node *list = NULL;
extBook_book_info *bki_data = NULL;
unsigned int rlen = 0;
unsigned char *path = L"E:\\extBook\\";
target_path = (unsigned short *)extBook_malloc(130);
full_path = (unsigned short *)extBook_malloc(130);
file_name = (unsigned short *)extBook_malloc(130);
bki_data = (extBook_book_info *)extBook_malloc(sizeof(extBook_book_info));
extBook_copy_ucs_string(L"E:\\extBook", &target_path);
mmi_ucs2cat((PS8)target_path,(PS8)L"\\*.bki");
if((hFile = FS_FindFirst((PU16)target_path, 0, 0, &file_info, (PU16)file_name, 130)) >= 0)
{
do
{
unsigned short *name = NULL;
unsigned short *flname = NULL;
unsigned char *ret = NULL;
extBook_scan_book_node *new_node = NULL;
int bki_file;
if(file_info.Attributes & (FS_ATTR_HIDDEN | FS_ATTR_SYSTEM | FS_ATTR_DIR))
{
continue;
}
memset(bki_data, 0, sizeof(extBook_book_info));
memset(full_path, 0, 130);
mmi_ucs2cpy((char *)full_path, path);
mmi_ucs2cat((char *)full_path, (char *)file_name);
bki_file = extBook_file_open(full_path, FS_READ_WRITE);
extBook_file_read(bki_file, sizeof(extBook_book_info), bki_data);
extBook_file_close(bki_file);
extBook_copy_ucs_string(file_name, &name);
flname = extBook_chang_bkiname_to_filename(name, bki_data);
ret = extBook_find_reading_filename((PS8)flname, list);
if(ret == NULL)
{
new_node = (extBook_scan_book_node *)extBook_malloc(sizeof(extBook_scan_book_node));
new_node->filename = (unsigned char *)extBook_malloc(130);
mmi_ucs2cpy(new_node->filename, (PS8)flname);
new_node->next = NULL;
extBook_add_booklist_data(&list, new_node);
}
extBook_free(name);
}while(FS_FindNext(hFile, &file_info, (PU16)file_name, 130) >= 0);
FS_FindClose(hFile);
}
extBook_write_booklist_to_file(list);
extBook_free_scanlist(list);
//extBook_free(target_path);
extBook_free(full_path);
extBook_free(file_name);
extBook_free(bki_data);
}