void BitMemExtractor::extract( const vector< byte_t >& in_buffer, const wstring& out_dir ) const { CMyComPtr< IInArchive > inArchive = openArchive( mLibrary, mFormat, in_buffer, *this ); ExtractCallback* extractCallbackSpec = new ExtractCallback( *this, inArchive, out_dir ); CMyComPtr< IArchiveExtractCallback > extractCallback( extractCallbackSpec ); if ( inArchive->Extract( NULL, static_cast< UInt32 >( -1 ), false, extractCallback ) != S_OK ) { throw BitException( extractCallbackSpec->getErrorMessage() ); } }
HRESULT CPlugin::ExtractFiles( bool decompressAllItems, const UInt32 *indices, UInt32 numIndices, bool silent, NExtract::NPathMode::EEnum pathMode, NExtract::NOverwriteMode::EEnum overwriteMode, const UString &destPath, bool passwordIsDefined, const UString &password) { CScreenRestorer screenRestorer; CProgressBox progressBox; CProgressBox *progressBoxPointer = NULL; if (!silent) { screenRestorer.Save(); progressBoxPointer = &progressBox; progressBox.Init( // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), g_StartupInfo.GetMsgString(NMessageID::kExtracting)); } CExtractCallbackImp *extractCallbackSpec = new CExtractCallbackImp; CMyComPtr<IFolderArchiveExtractCallback> extractCallback(extractCallbackSpec); extractCallbackSpec->Init( CP_OEMCP, progressBoxPointer, /* GetDefaultName(m_FileName, m_ArchiverInfo.Extension), m_FileInfo.MTime, m_FileInfo.Attributes, */ passwordIsDefined, password); if (decompressAllItems) return m_ArchiveHandler->Extract(pathMode, overwriteMode, destPath, BoolToInt(false), extractCallback); else { CMyComPtr<IArchiveFolder> archiveFolder; _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder); return archiveFolder->Extract(indices, numIndices, BoolToInt(true), // includeAltStreams BoolToInt(false), // replaceAltStreamChars pathMode, overwriteMode, destPath, BoolToInt(false), extractCallback); } }
void BitMemExtractor::extract( const vector< byte_t >& in_buffer, vector< byte_t >& out_buffer, unsigned int index ) const { CMyComPtr< IInArchive > inArchive = openArchive( mLibrary, mFormat, in_buffer, *this ); NCOM::CPropVariant prop; inArchive->GetProperty( index, kpidSize, &prop ); MemExtractCallback* extractCallbackSpec = new MemExtractCallback( *this, inArchive, out_buffer ); const UInt32 indices[] = { index }; CMyComPtr< IArchiveExtractCallback > extractCallback( extractCallbackSpec ); if ( inArchive->Extract( indices, 1, false, extractCallback ) != S_OK ) { throw BitException( extractCallbackSpec->getErrorMessage() ); } }
HRESULT CPanelCopyThread::ProcessVirt() { /* CMyComPtr<IFolderSetReplaceAltStreamCharsMode> iReplace; FolderOperations.QueryInterface(IID_IFolderSetReplaceAltStreamCharsMode, &iReplace); if (iReplace) { RINOK(iReplace->SetReplaceAltStreamCharsMode(ReplaceAltStreamChars ? 1 : 0)); } */ if (options->testMode) { CMyComPtr<IArchiveFolder> archiveFolder; FolderOperations.QueryInterface(IID_IArchiveFolder, &archiveFolder); if (!archiveFolder) return E_NOTIMPL; CMyComPtr<IFolderArchiveExtractCallback> extractCallback2; RINOK(ExtractCallback.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2)); NExtract::NPathMode::EEnum pathMode = NExtract::NPathMode::kCurPaths; // NExtract::NPathMode::kFullPathnames; Result = archiveFolder->Extract(&Indices.Front(), Indices.Size(), BoolToInt(options->includeAltStreams), BoolToInt(options->replaceAltStreamChars), pathMode, NExtract::NOverwriteMode::kAsk, options->folder, BoolToInt(true), extractCallback2); } else Result = FolderOperations->CopyTo( BoolToInt(options->moveMode), &Indices.Front(), Indices.Size(), BoolToInt(options->includeAltStreams), BoolToInt(options->replaceAltStreamChars), options->folder, ExtractCallback); if (Result == S_OK && !ExtractCallbackSpec->ThereAreMessageErrors && (!options->hashMethods.IsEmpty() || options->testMode)) { CProgressMessageBoxPair &pair = GetMessagePair(false); // GetMessagePair(ExtractCallbackSpec->Hash.NumErrors != 0); AddHashBundleRes(pair.Message, Hash, FirstFilePath); } return Result; }
bool vms7zipArchive::Extract(LPCSTR pszArchive, LPCSTR pszOutFolder) { CInFileStream *fileSpec = new CInFileStream; CMyComPtr <IInStream> spFile = fileSpec; m_errExtract = AEE_GENERIC_ERROR; if (false == fileSpec->Open(pszArchive)) return false; CMyComPtr <IInArchive> spArc; vms7zipFormatDLL dll; if (false == Find7zipDLL (dll, pszArchive, true, spFile, spArc) && false == Find7zipDLL (dll, pszArchive, false, spFile, spArc)) return false; m_errExtract = AEE_NO_ERROR; char sz [MY_MAX_PATH]; fsGetFileName (pszArchive, sz); vms7zipArchiveExtractCallback aec (spArc, pszOutFolder, m_pAC, sz); HRESULT hr; if (FAILED (hr=spArc->Extract (NULL, (UInt32)-1, 0, &aec))) { spArc = NULL; m_errExtract = aec.is_AbortedByUser () ? AEE_ABORTED_BY_USER : AEE_GENERIC_ERROR; return false; } spArc = NULL; if (*aec.get_FurtherExtractFile () != 0) { bool b = Extract (aec.get_FurtherExtractFile (), pszOutFolder); DeleteFile (aec.get_FurtherExtractFile ()); return b; } return true; }