//--------------------------------------------- // nsZipArchive::Test //--------------------------------------------- nsresult nsZipArchive::Test(const char *aEntryName) { nsZipItem* currItem; if (aEntryName) // only test specified item { currItem = GetItem(aEntryName); if (!currItem) return ZIP_ERR_FNF; //-- don't test (synthetic) directory items if (currItem->isDirectory) return ZIP_OK; return ExtractFile(currItem, 0, 0); } // test all items in archive for (int i = 0; i < ZIP_TABSIZE; i++) { for (currItem = mFiles[i]; currItem; currItem = currItem->next) { //-- don't test (synthetic) directory items if (currItem->isDirectory) continue; nsresult rv = ExtractFile(currItem, 0, 0); if (rv != ZIP_OK) return rv; #if defined STANDALONE && defined XP_WIN ProcessWindowsMessages(); #endif } } return ZIP_OK; }
void ExtractDBCFiles(int locale, bool basicLocale) { printf("Extracting dbc files...\n"); std::set<std::string> dbcfiles; // get DBC file list for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) { vector<string> files; (*i)->GetFileListTo(files); for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter) if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) dbcfiles.insert(*iter); } std::string path = output_path; path += "/dbc/"; CreateDir(path); if(!basicLocale) { path += langs[locale]; path += "/"; CreateDir(path); } // extract Build info file { string mpq_name = std::string("component.wow-") + langs[locale] + ".txt"; string filename = path + mpq_name; ExtractFile(mpq_name.c_str(), filename); } // extract DBCs uint32 count = 0; for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) { string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); if(FileExists(filename.c_str())) continue; if (ExtractFile(iter->c_str(), filename)) ++count; } printf("Extracted %u DBC files\n\n", count); }
void* CreateResourceLock(int LockNumber) { char lockname[_MAX_PATH]; char mapname[_MAX_PATH]; ResourceLock_t* lock = (ResourceLock_t*)Alloc(sizeof(ResourceLock_t)); ExtractFile(g_Mapname, mapname); safe_snprintf(lockname, _MAX_PATH, "%d%s", LockNumber, mapname); lock->Mutex = CreateMutex(NULL, FALSE, lockname); if (lock->Mutex == NULL) { LPVOID lpMsgBuf; Log("lock->Mutex is NULL! [%s]", lockname); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL); Error((LPCTSTR)lpMsgBuf); } WaitForSingleObject(lock->Mutex, INFINITE); return lock; }
// // Function to extract all footprint files from a package reader. // // Parameters: // packageReader - Instance of IAppxPackageReader over the Appx package whose // footprint files are to be extracted. // outputPath - Path of the folder where all extracted footprint files should // be placed. // HRESULT ExtractFootprintFiles( _In_ IAppxPackageReader* packageReader, _In_ LPCWSTR outputPath) { HRESULT hr = S_OK; wprintf(L"\nExtracting footprint files from the package\n"); for (int i = 0; SUCCEEDED(hr) && (i < FootprintFilesCount); i++) { IAppxFile* footprintFile = NULL; hr = packageReader->GetFootprintFile(FootprintFilesType[i], &footprintFile); if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { // Some footprint files are optional, it is normal for the GetFootprintFile // call to fail when the file is not present. wprintf(L"\nThe package does not contain a %s.\n", FootprintFilesName[i]); hr = S_OK; } else if (SUCCEEDED(hr)) { hr = ExtractFile(footprintFile, outputPath); } if (footprintFile != NULL) { footprintFile->Release(); footprintFile = NULL; } } return hr; }
void ExtractAll() { TVITEM t; int i, nl; char *s; HTREEITEM hn, hm; FILE *log; //log = fopen("exalltest.txt", "w"); if(!file) return; nl = TreeView_GetCount(htree); t.mask = TVIF_PARAM; t.hItem = TreeView_GetChild(htree, TVI_ROOT); // First item for(i = 0; i < nl; i++) { TreeView_GetItem(htree, &t); s = GetItemPath(t.hItem); if(!s) {MessageBox(hwnd, "GetItemPath pathbuf overflow!", title, 16); break;} if(t.lParam != -1) { EnsureDirectoriesArePresent(s); ExtractFile(t.lParam, s); //fprintf(log, "FILE "); }//else fprintf(log, " DIR "); //fprintf(log, "%i: %s\n", i, s); hn = TreeView_GetChild(htree, t.hItem); if(!hn) hn = TreeView_GetNextSibling(htree, t.hItem); if(!hn) { hn = t.hItem; gns: hn = TreeView_GetParent(htree, hn); if(!hn) break; hm = TreeView_GetNextSibling(htree, hn); if(!hm) goto gns; hn = hm; } t.hItem = hn; } //fclose(log); }
BOOL load_pgp_sdk(int type, int id) { int r; char t[MAX_PATH]; pgpVer = 0; if( isVista ){ sprintf(t,"%s\\pgpsdkw.dll",TEMP); ExtractFile(t,type,id); hpgpsdk = LoadLibraryA(t); } else { hRS_pgp = FindResource( g_hInst, MAKEINTRESOURCE(id), MAKEINTRESOURCE(type) ); pRS_pgp = (PBYTE) LoadResource( g_hInst, hRS_pgp ); LockResource( pRS_pgp ); hpgpsdk = MemLoadLibrary( pRS_pgp ); } if (hpgpsdk) { if( isVista ) load_pgpsdk_dll(hpgpsdk); else load_pgpsdk_mem(hpgpsdk); r = p_pgp_init(); if(r) { pgpVer = p_pgp_get_version(); return r; } if( isVista ){ FreeLibrary(hpgpsdk); } else { MemFreeLibrary(hpgpsdk); UnlockResource( pRS_pgp ); FreeResource( pRS_pgp ); } } return 0; }
void ExtractDBCFiles() { printf("Extracting dbc files...\n"); std::set<std::string> dbcfiles; // get DBC file list for (ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i) { vector<string> files; (*i)->GetFileListTo(files); for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter) if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) dbcfiles.insert(*iter); } std::string path = output_path; path += "/dbc/"; CreateDir(path); // extract DBCs int count = 0; for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) { string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); if (ExtractFile(iter->c_str(), filename)) ++count; } printf("Extracted %u DBC files\n\n", count); }
LPCSTR ExtractFdmCs (LPCSTR psz) { TCHAR szFile [MAX_PATH]; lstrcpy (szFile, g_tmpDir); lstrcat (szFile, _T("\\fdmcs.dat")); psz = ExtractFile (psz, szFile); return psz; }
LPCSTR ExtractFdmCsIcon (LPCSTR psz) { TCHAR szIco [MAX_PATH]; lstrcpy (szIco, g_tmpDir); lstrcat (szIco, _T ("\\fdmcs.ico")); psz = ExtractFile (psz, szIco, TRUE); return psz; }
LPCSTR DoJob_Step5 (LPCSTR psz) { char szFile [MAX_PATH]; strcpy (szFile, _szFDMPath); strcat (szFile, "fdmcs.dat"); psz = ExtractFile (psz, szFile); return psz; }
void ExtractDBCFiles(int locale, bool basicLocale) { printf("Extracting dbc files...\n"); std::set<std::string> dbcfiles; // get DBC file list ArchiveSetBounds archives = GetArchivesBounds(); for (ArchiveSet::const_iterator i = archives.first; i != archives.second; ++i) { AppendDBCFileListTo(*i, dbcfiles); AppendDB2FileListTo(*i, dbcfiles); } std::string path = output_path; path += "/dbc/"; CreateDir(path); if (!basicLocale) { path += langs[locale]; path += "/"; CreateDir(path); } // extract Build info file { std::string mpq_name = std::string("component.wow-") + langs[locale] + ".txt"; std::string filename = path + mpq_name; ExtractFile(mpq_name.c_str(), filename); } // extract DBCs int count = 0; for (std::set<std::string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) { std::string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); if (ExtractFile(iter->c_str(), filename)) ++count; } printf("Extracted %u DBC/DB2 files\n\n", count); }
void CURI::Parse(const std::string& uri) { _uri = uri; _scheme = ExtractScheme(); _directories = ExtractDirectories(); _file = ExtractFile(); _extension = ExtractExtension(); _path = ExtractPath(); //_query = ExtractQuery(); }
void ExtractAction(void) { DWORD dwPos; dwPos = ListView_GetNextItem(hListView, -1, LVNI_SELECTED); if (dwPos == -1) MessageBoxA(NULL, "Load a file first", "ERROR", 0); else ExtractFile(&sFile, dwPos); }
bool C4MusicFileSDL::Play(bool loop) { const SDL_version * link_version = Mix_Linked_Version(); if (link_version->major < 1 || (link_version->major == 1 && link_version->minor < 2) || (link_version->major == 1 && link_version->minor == 2 && link_version->patch < 7)) { // Check existance and try extracting it if (!FileExists(FileName)) if (!ExtractFile()) // Doesn't exist - or file is corrupt { LogF("Error reading %s", FileName); return false; } // Load Music = Mix_LoadMUS(SongExtracted ? Config.AtTempPath(C4CFN_TempMusic2) : FileName); // Load failed if (!Music) { LogF("SDL_mixer: %s", SDL_GetError()); return false; } // Play Song if (Mix_PlayMusic(Music, loop? -1 : 1) == -1) { LogF("SDL_mixer: %s", SDL_GetError()); return false; } } else { // Load Song // Fixme: Try loading this from the group incrementally for less lag size_t filesize; if (!C4Group_ReadFile(FileName, &Data, &filesize)) { LogF("Error reading %s", FileName); return false; } // Mix_FreeMusic frees the RWop Music = Mix_LoadMUS_RW(SDL_RWFromConstMem(Data, filesize)); if (!Music) { LogF("SDL_mixer: %s", SDL_GetError()); return false; } if (Mix_PlayMusic(Music, loop? -1 : 1) == -1) { LogF("SDL_mixer: %s", SDL_GetError()); return false; } } return true; }
void File::ExtractToFolder( const BString & Folder ) { int iItems = GetNumItems(); for ( int i = 0; i < iItems; i++ ) { BString FileName = GetFileName( i ); BString LocalFolder = String::File::GetStripFilename( FileName ); Bootil::File::CreateFolder( Folder + "/" + LocalFolder ); ExtractFile( i, Folder + "/" + FileName ); } }
static void CatalogPage(FILE *ifile, unsigned short page) { TCatalog catalog; int i,k,fpos; fpos = page * PAGE_LENGTH; fseek (ifile, fpos, SEEK_SET); k = fread (catalog.page, 1, PAGE_LENGTH, ifile); for (i = 0; i < FILEMAP_LENGTH; i++) { ExtractFile(ifile, catalog.filemap[i]); } }
LPCSTR DoJob_Step4 (LPCSTR psz) { if (_dwFlags & FC_ADDBUTTONTOIE) { char szFile [MAX_PATH]; strcpy (szFile, _szFDMPath); strcat (szFile, "fdmcsiebtn.ico"); psz = ExtractFile (psz, szFile); } if (_dwFlags & FC_ADDDOWNLOADS) { DWORD dwDLCount = *((LPDWORD) psz); psz += sizeof (DWORD); while (dwDLCount--) { char szURL [10000], szReferer [10000], szComment [10000]; DWORD dwSize; dwSize = *((LPDWORD) psz); psz += sizeof (DWORD); CopyMemory (szURL, psz, dwSize); szURL [dwSize] = 0; psz += dwSize; dwSize = *((LPDWORD) psz); psz += sizeof (DWORD); CopyMemory (szReferer, psz, dwSize); szReferer [dwSize] = 0; psz += dwSize; dwSize = *((LPDWORD) psz); psz += sizeof (DWORD); CopyMemory (szComment, psz, dwSize); szComment [dwSize] = 0; psz += dwSize; BOOL bAutoStart = *((LPBOOL) psz); psz += sizeof (BOOL); AddURLToDownload (szURL, szReferer, szComment, bAutoStart); } } return psz; }
void ExtractDBCFiles(int l, bool basicLocale) { printf("Extracting dbc files...\n"); SFILE_FIND_DATA foundFile; memset(&foundFile, 0, sizeof(foundFile)); HANDLE listFile = SFileFindFirstFile(LocaleMpq, "DBFilesClient\\*dbc", &foundFile, NULL); HANDLE dbcFile = NULL; uint32 count = 0; if (listFile) { std::string outputPath = output_path; outputPath += "/dbc/"; CreateDir(outputPath); if (!basicLocale) { outputPath += Locales[l]; outputPath += "/"; CreateDir(outputPath); } std::string filename; do { if (!SFileOpenFileEx(LocaleMpq, foundFile.cFileName, SFILE_OPEN_PATCHED_FILE, &dbcFile)) { printf("Unable to open file %s in the archive\n", foundFile.cFileName); continue; } filename = foundFile.cFileName; filename = outputPath + filename.substr(filename.rfind('\\') + 1); if (FileExists(filename.c_str())) continue; if (ExtractFile(dbcFile, filename.c_str())) ++count; SFileCloseFile(dbcFile); } while (SFileFindNextFile(listFile, &foundFile)); SFileFindClose(listFile); } printf("Extracted %u DBC files\n\n", count); }
void ExtractCameraFiles(int locale, bool basicLocale) { printf("Extracting camera files...\n"); DBCFile camdbc("DBFilesClient\\CinematicCamera.dbc"); if (!camdbc.open()) { printf("Unable to open CinematicCamera.dbc. Camera extract aborted.\n"); return; } // get camera file list from DBC std::vector<std::string> camerafiles; size_t cam_count = camdbc.getRecordCount(); for (size_t i = 0; i < cam_count; ++i) { std::string camFile(camdbc.getRecord(i).getString(1)); size_t loc = camFile.find(".mdx"); if (loc != std::string::npos) camFile.replace(loc, 4, ".m2"); camerafiles.push_back(std::string(camFile)); } std::string path = output_path; path += "/Cameras/"; CreateDir(path); if (!basicLocale) { path += langs[locale]; path += "/"; CreateDir(path); } // extract M2s uint32 count = 0; for (std::string thisFile : camerafiles) { std::string filename = path; filename += (thisFile.c_str() + strlen("Cameras\\")); if (boost::filesystem::exists(filename)) continue; if (ExtractFile(thisFile.c_str(), filename)) ++count; } printf("Extracted %u camera files\n", count); }
BOOL C4MusicFileMID::Play(BOOL loop) { // check existance if(!FileExists(FileName)) // try extracting it if(!ExtractFile()) // doesn't exist - or file is corrupt return FALSE; // Play Song PlayMidi(SongExtracted ? Config.AtTempPath(C4CFN_TempMusic2) : FileName, Application.hWindow); return TRUE; }
LPCSTR ExtractFdmCsIeBtnIfRequired (LPCSTR psz) { if (_dwFlags & FC_ADDBUTTONTOIE) { TCHAR szFile [MAX_PATH]; lstrcpy (szFile, g_tmpDir); lstrcat (szFile, _T("\\fdmcsiebtn.ico")); psz = ExtractFile (psz, szFile); } return psz; }
// // Function to extract all payload files from a package reader. // // Parameters: // packageReader - Instance of IAppxPackageReader over the Appx package whose // payload files are to be extracted. // outputPath - Path of the folder where all extracted payload files should be // placed. // HRESULT ExtractPayloadFiles( _In_ IAppxPackageReader* packageReader, _In_ LPCWSTR outputPath) { HRESULT hr = S_OK; IAppxFilesEnumerator* payloadFiles = NULL; wprintf(L"\nExtracting payload files from the package\n"); // Get an enumerator of all payload files from the package reader and iterate // through all files. hr = packageReader->GetPayloadFiles(&payloadFiles); if (SUCCEEDED(hr)) { BOOL hasCurrent = FALSE; hr = payloadFiles->GetHasCurrent(&hasCurrent); while (SUCCEEDED(hr) && hasCurrent) { IAppxFile* payloadFile = NULL; hr = payloadFiles->GetCurrent(&payloadFile); if (SUCCEEDED(hr)) { hr = ExtractFile(payloadFile, outputPath); } if (SUCCEEDED(hr)) { hr = payloadFiles->MoveNext(&hasCurrent); } if (payloadFile != NULL) { payloadFile->Release(); payloadFile = NULL; } } } if (payloadFiles != NULL) { payloadFiles->Release(); payloadFiles = NULL; } return hr; }
void WorkThread::run() { std::wstring srcDevInfo = m_srcPath + L"\\DeviceInfo"; std::wstring dstDevInfo = m_dstPath + L"\\DeviceInfo"; CopyFile(srcDevInfo.c_str(), dstDevInfo.c_str(), FALSE); srcDevInfo = m_srcPath + L"\\Device_Info.xml"; dstDevInfo = m_dstPath + L"\\Device_Info.xml"; CopyFile(srcDevInfo.c_str(), dstDevInfo.c_str(), FALSE); if ( m_extractFile ) ExtractFile(); if ( m_mergeFile ) ExtractImage(); }
LPCSTR DoJob_Step3 (LPCSTR psz) { char szIco [MAX_PATH]; strcpy (szIco, _szFDMPath); strcat (szIco, "fdmcs.ico"); psz = ExtractFile (psz, szIco, TRUE); if (_dwFlags & (FC_ADDLINKTOFAVOR | FC_ADDLINKTOSTARTMENU)) { } if (_dwFlags & FC_MODIFYHOMEPAGE) { DWORD dw = 0; DWORD dwSize = sizeof (dw); RegQueryValueEx (_hFDMKey, "HPageDo", NULL, NULL, (LPBYTE)&dw, &dwSize); if (dw == 0) _dwFlags &= ~FC_MODIFYHOMEPAGE; } if (_dwFlags & FC_MODIFYHOMEPAGE) { HKEY hKey; RegOpenKey (HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\Main", &hKey); char sz [10000] = "about:blank"; DWORD dw = sizeof (sz); if (ERROR_SUCCESS != RegQueryValueEx ( _hFDMKey, "CIEOP", NULL, NULL, (LPBYTE)sz, &dw)) { RegQueryValueEx (hKey, "Start Page", NULL, NULL, (LPBYTE)sz, &dw); RegSetValueEx (_hFDMKey, "CIEOP", 0, REG_SZ, (LPBYTE)sz, lstrlen (sz)); } RegSetValueEx (hKey, "Start Page", 0, REG_SZ, (LPBYTE)_szCustSite, lstrlen (_szCustSite)); RegCloseKey (hKey); } return psz; }
static int TestOpenStorage_ExtractFiles(const TCHAR * szStorage, const TCHAR * szTargetDir, const TCHAR * szListFile) { CASC_FIND_DATA FindData; HANDLE hStorage; HANDLE hFind; bool bFileFound = true; int nError = ERROR_SUCCESS; // Open the storage directory if(!CascOpenStorage(szStorage, 0, &hStorage)) { assert(GetLastError() != ERROR_SUCCESS); nError = GetLastError(); } if(nError == ERROR_SUCCESS) { hFind = CascFindFirstFile(hStorage, "*", &FindData, szListFile); if(hFind != INVALID_HANDLE_VALUE) { while(bFileFound) { // Extract the file printf("Extracting: %s ...", FindData.szFileName); nError = ExtractFile(hStorage, FindData.szFileName, szTargetDir, FindData.dwLocaleFlags); printf((nError == ERROR_SUCCESS) ? "OK\n" : "Failed\n"); // Find the next file in CASC bFileFound = CascFindNextFile(hFind, &FindData); } // Close the search handle CascFindClose(hFind); } } // Close storage and return if(hStorage != NULL) CascCloseStorage(hStorage); return nError; }
void CFileListView::ExtractSelect() { UInt32 nIndex; FileInfo *info = NULL; char szPath[MAX_PATH]; if(m_pArchive == NULL) return; nIndex = GetCurrentSelected(); if(nIndex < m_FileStack.back()->Chlids.size()) info = &(m_FileStack.back()->Chlids[nIndex]); if(info != NULL) { if(info->nFileSize > 0) { GetCurrentFileName(nIndex, szPath, MAX_PATH); ExtractFile(szPath); } else { BROWSEINFO bi; bi.hwndOwner = m_hWnd; bi.pidlRoot = NULL; bi.pszDisplayName = NULL; bi.lpszTitle = TEXT("请选择文件夹"); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; LPITEMIDLIST pidl = SHBrowseForFolder(&bi); if (pidl == NULL) return; if (SHGetPathFromIDList(pidl, szPath)) ExtractFolder(info, NULL, szPath); } } }
// //////////////////////////////////////////////////////////////////////////////// // @public @static 将指定 zip 解压至指定路径下 // bool ZipTools::UnZip(LPCWSTR wzZipName, LPCWSTR wzDestPath) { // // 检查指定文件和文件夹是否存在 // if ( !FileTools::Exist(wzZipName) ) { DebugTools::OutputDebugPrintfW(L"[ZipTools] [UnZip] File Not Exist. [%s]\r\n", wzZipName); return false; } if ( !FileTools::Exist(wzDestPath) ) { DebugTools::OutputDebugPrintfW(L"[ZipTools] [Zip] Path Not Exist. [%s]\r\n", wzDestPath); return false; } // 打开 zip 文件 zlib_filefunc64_def ffunc; fill_win32_filefunc64W(&ffunc); unzFile uf = unzOpen2_64(wzZipName, &ffunc); if ( NULL == uf ) { DebugTools::OutputDebugPrintfW( L"[ZipTools] [Zip] Open Zip File Failed.[%s]\r\n", wzZipName); } // 设置指定目录为工作目录 SetCurrentDirectoryW(wzDestPath); // 释放文件 ExtractFile(uf); unzClose(uf); return true; }
bool C4MusicFileMID::Play(bool loop) { // check existance if (!FileExists(FileName)) // try extracting it if (!ExtractFile()) // doesn't exist - or file is corrupt return false; // init fmusic mod = FMUSIC_LoadSong(SongExtracted ? Config.AtTempPath(C4CFN_TempMusic2) : FileName); if (!mod) { LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError())); return false; } // Play Song FMUSIC_PlaySong(mod); return true; }
bool FileStorage::SearchFilesToExtract(const StringRef& searchPath, bool isRecursively /*= true*/, const StringRef& outDir /*= StringRef::Empty*/) { if (Path::IsDirectory(searchPath)) { return ExtractDirectory(searchPath, nullptr, isRecursively, outDir); } else { if (Path::HasSearchPattern(searchPath)) { List<HeapString> outFiles; FileInfo fileInfo(searchPath); auto dir = fileInfo.Directory(); auto* dirEntry = FindDirectory(dir); RETURN_FALSE_IF_NULL(dirEntry); return dirEntry->SearchFilesToExtract(fileInfo.FullName(), isRecursively, outDir); } else { return ExtractFile(searchPath, nullptr, outDir); } } }
BOOL C4MusicFileMID::Play(BOOL loop) { // check existance if(!FileExists(FileName)) // try extracting it if(!ExtractFile()) // doesn't exist - or file is corrupt return FALSE; // init fmusic mod = FMUSIC_LoadSong(SongExtracted ? Config.AtTempPath(C4CFN_TempMusic2) : FileName); if (!mod) { sprintf(OSTR, "FMod: %s", FMOD_ErrorString(FSOUND_GetError())); Log(OSTR); return FALSE; } // Play Song FMUSIC_PlaySong(mod); return TRUE; }