unsigned NEZ_extractMem(void *data, unsigned len, void **ppbuf) { HUNZM hunzm = 0; void *outputbuf = 0; /* try */ do { ZIP_LOCAL_HEADER unzinfo; unsigned outputsize; hunzm = unzmOpen(data, len); if (hunzm == 0) break; unzmGoToFirstFile(hunzm); do { unzmGetCurrentFileInfo(hunzm, &unzinfo); if (CheckExt(unzinfo.fname)) { outputbuf = malloc(unzinfo.size_inf + 8); if (outputbuf == 0) break; outputsize = unzmExtract(hunzm, outputbuf); if (outputsize == 0) break; unzmClose(hunzm); *ppbuf = outputbuf; return outputsize; } } while (unzmGoToNextFile(hunzm) == 0); break; } while(0); /* finaly */ if (outputbuf != 0) free(outputbuf); if (hunzm != 0) unzmClose(hunzm); return 0; }
static void BuildSkinList(HWND hwndList, TCHAR *szExt, int nExtLength = -1, bool start = true) { if (start) { static TCHAR mirPath[MAX_PATH]; GetModuleFileName(NULL, mirPath, _countof(mirPath)); if (TCHAR *p = _tcsrchr(mirPath, _T('\\'))) *p = 0; SetCurrentDirectory(mirPath); SendMessage(hwndList, LB_RESETCONTENT, 0, 0); nExtLength = (int)mir_tstrlen(szExt); SendMessage(hwndList, WM_SETREDRAW, FALSE, 0); } WIN32_FIND_DATA ffd = { 0 }; HANDLE h = FindFirstFile(_T("*.*"), &ffd); if (h != INVALID_HANDLE_VALUE) { do { if (!mir_tstrcmp(ffd.cFileName, _T("")) || !mir_tstrcmp(ffd.cFileName, _T(".")) || !mir_tstrcmp(ffd.cFileName, _T(".."))) continue; if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { SetCurrentDirectory(ffd.cFileName); BuildSkinList(hwndList, szExt, nExtLength, false); SetCurrentDirectory(_T("..")); } else { if (CheckExt(ffd.cFileName, szExt, nExtLength)) { TSkinListItem *dat = new TSkinListItem(ffd.cFileName); DWORD dwItem = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)ffd.cFileName); SendMessage(hwndList, LB_SETITEMDATA, dwItem, (LPARAM)dat); } } } while (FindNextFile(h, &ffd)); FindClose(h); } if (start) { SendMessage(hwndList, WM_SETREDRAW, TRUE, 0); RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE); } }
void FillListBox(HWND hwnd, GRPDirEntry *table, DWORD fullnum, char* filter) { DWORD i; int index; char str[MAX_PATH+200],name[13],ext[6]; if (filter==NULL) lstrcpy(ext,"*"); SendDlgItemMessage(hwnd,ID_PROGRESS,PBM_SETPOS,(UINT)0,0L); SendDlgItemMessage(hwnd,ID_LIST,LB_RESETCONTENT,0,0L); for (i=0;i<fullnum;i++) { lstrcpyn(name,table[i].fileName,13); if (filter==NULL) { wsprintf(str,"%-12s\t%ld KB",name,table[i].fileSize/1024); index=(int)SendDlgItemMessage(hwnd,ID_LIST,LB_ADDSTRING,0,(LPARAM)str); if (index!=LB_ERR) SendDlgItemMessage(hwnd,ID_LIST,LB_SETITEMDATA,(WPARAM)index,(LPARAM)i); if (GetFileExtension(name)!=NULL) { ext[1]=0; lstrcat(ext,GetFileExtension(name)); if (SendDlgItemMessage(hwnd,ID_FILTER,CB_FINDSTRINGEXACT,(WPARAM)(-1),(LPARAM)ext)==CB_ERR) SendDlgItemMessage(hwnd,ID_FILTER,CB_ADDSTRING,0,(LPARAM)ext); } } else if (CheckExt(name,filter+2)) { wsprintf(str,"%-12s\t%ld KB",name,table[i].fileSize/1024); index=(int)SendDlgItemMessage(hwnd,ID_LIST,LB_ADDSTRING,0,(LPARAM)str); if (index!=LB_ERR) SendDlgItemMessage(hwnd,ID_LIST,LB_SETITEMDATA,(WPARAM)index,(LPARAM)i); } SendDlgItemMessage(hwnd,ID_PROGRESS,PBM_SETPOS,MulDiv(100,i+1,fullnum),0L); UpdateWindow(hwnd); } SendDlgItemMessage(hwnd,ID_PROGRESS,PBM_SETPOS,(UINT)0,0L); }