int packOpenAsync(const char* filename) { int fd = -1; packItem* temp = NULL; temp = fileItem; if(fileItem==NULL) return -1; while( strcmp(filename,(char*)temp->date.name) ) { temp = temp->next; if(temp==NULL) return -1; } fd = io_fopen(name,IO_RDONLY); io_fseek(fd,temp->date.offset,IO_SEEK_SET); return fd; }
image_p image_load_jpg(const char* filename, int displaymode) { image_p pimage = NULL; int size; char *mbuf; int handle = io_fopen(filename,IO_RDONLY); if(handle == 0) return 0; size = io_fsize(handle); mbuf = (char*) malloc(size); io_fread(mbuf,1,size,handle); io_fclose(handle); pimage = image_load_jpg_buf(mbuf,size,displaymode); SAFE_FREE(mbuf); return pimage; }
int PMP_Load (const char *name) { //check file; pmp_init(); int handle = io_fopen(name,IO_RDONLY); if(handle <= 0){ flags = 0; return 0; } else{ io_fclose(handle); strncpy(filename,name,256); return 1; } }
////////////////////////////////////////////////////////////////////////// //load bmp //support 24/32 bmp (NOT support 16) ////////////////////////////////////////////////////////////////////////// image_p image_load_bmp(const char* filename, int displaymode) { image_p pimage = NULL; int size ; uint8_t* pbuf; int fd = io_fopen(filename,IO_RDONLY); if(fd == 0) return 0; size = io_fsize(fd); pbuf = (uint8_t*)malloc(size); io_fread(pbuf,1,size,fd); io_fclose(fd); pimage = image_load_bmp_buf((const char*)pbuf,size,displaymode); SAFE_FREE(pbuf); return pimage; }
int packInit(const char* filename) { int i = 0; packItem* temp = NULL; packCleanRes(); fd = io_fopen(filename,IO_RDONLY); if(fd <= 0) return -1; fileInfo = (packInfo*) safe_malloc (sizeof(packInfo)); io_fseek(fd,(int)(-sizeof(packInfo)),IO_SEEK_END); io_fread(fileInfo,sizeof(packInfo),1,fd); if(fileInfo->VER!=0x01000000) { // 如果不是pack压缩包则取消读取 packCleanRes(); return -1; } io_fseek(fd,(int)(-(sizeof(packInfo)+sizeof(packDate)*fileInfo->nums)),IO_SEEK_END); for(i=0;i<fileInfo->nums;i++) { if(fileItem==NULL) { fileItem = (packItem*) safe_malloc (sizeof(packItem)); temp = fileItem; io_fread(&temp->date,sizeof(packDate),1,fd); temp->next = NULL; } if((i!=0) && (temp->next==NULL)) { temp->next = (packItem*) safe_malloc (sizeof(packItem)); temp = temp->next; io_fread(&temp->date,sizeof(packDate),1,fd); temp->next = NULL; } } if(name==NULL) { name = (char*) safe_malloc (strlen(filename)); strcpy(name,filename); } //rewind((FILE*)fd); io_fseek(fd,0,IO_SEEK_SET); //printf("first fd address: 0x%x\n",fd); return fd; }