/** * * Extract one given file. * * @param deflator IN: Pointer to the cabinet decompressor * @param file IN: Pointer to file under decompression * @param destDirector IN: Destination directory * @return * On Success LINUXCAB_SUCCESS * On Failure LINUXCAB_ERROR * **/ static unsigned int ExtractFile (struct mscab_decompressor* deflator, struct mscabd_file* file, const char* destDirectory) { size_t sz; // copy it into a string as SetupPath will do an in place text manipulation char fileName[strlen(file->filename)+1]; strcpy(fileName, file->filename); // add the target directory to the file path sz = strlen(destDirectory)+ 1 + strlen(fileName)+ 1; { char outCabFile[sz]; sprintf (outCabFile, "%s/%s", destDirectory, fileName); // set up the path if it does not exist if (SetupPath(outCabFile) != LINUXCAB_SUCCESS) { return LINUXCAB_ERROR; } #ifdef VMX86_DEBUG sLog(log_info, "Extracting %s .... \n", outCabFile ); #endif // Extract File if (deflator->extract(deflator,file,outCabFile) != MSPACK_ERR_OK) { return LINUXCAB_ERR_EXTRACT; } } return LINUXCAB_SUCCESS; }
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShowCmd) { ReserveBottomMemory(); tick_thd.Start(); int argc=0; wchar* cmd_line=GetCommandLineA(); wchar** argv=CommandLineToArgvA(cmd_line,&argc); if(strstr(cmd_line,"NoConsole")==0) { if (AllocConsole()) { freopen("CON","w",stdout); freopen("CON","w",stderr); freopen("CON","r",stdin); } SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); } SetupPath(); //SetUnhandledExceptionFilter(&ExeptionHandler); __try { int dc_init(int argc,wchar* argv[]); void dc_run(); void dc_term(); dc_init(argc,argv); #ifdef _WIN64 setup_seh(); #endif dc_run(); dc_term(); } __except( ExeptionHandler(GetExceptionInformation()) ) { printf("Unhandled exception - Emulation thread halted...\n"); } SetUnhandledExceptionFilter(0); return 0; }