"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "other-licenses/7zstub/src/7zip/Bundles/SFXSetup-moz/ExtractEngine.cpp" between
UXP-2019.03.27.tar.gz and UXP-2019.06.08.tar.gz

About: Basilisk is a full-featured, optimized browser derived from the code behind the pre-Servo Firefox browser (29–56 era). UXP = Unified XUL Platform. Source code.

ExtractEngine.cpp  (UXP-2019.03.27):ExtractEngine.cpp  (UXP-2019.06.08)
// ExtractEngine.cpp // ExtractEngine.cpp
#include "StdAfx.h" #include "StdAfx.h"
#include "ExtractEngine.h" #include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#include "Common/StringConvert.h" #include "../../../Windows/Thread.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/Thread.h"
#include "../../UI/Common/OpenArchive.h" #include "../../UI/Common/OpenArchive.h"
#include "../../UI/Explorer/MyMessages.h" #include "../../UI/FileManager/FormatUtils.h"
#include "../../FileManager/FormatUtils.h" #include "../../UI/FileManager/LangUtils.h"
#include "ExtractCallback.h" #include "ExtractCallbackSfx.h"
#include "ExtractEngine.h"
using namespace NWindows; using namespace NWindows;
using namespace NFile;
using namespace NDir;
static LPCSTR const kCantFindArchive = "Can not find archive file";
static LPCSTR const kCantOpenArchive = "Can not open the file as archive";
struct CThreadExtracting struct CThreadExtracting
{ {
CArchiveLink ArchiveLink; CCodecs *Codecs;
FString FileName;
FString DestFolder;
CExtractCallbackImp *ExtractCallbackSpec; CExtractCallbackImp *ExtractCallbackSpec;
CMyComPtr<IArchiveExtractCallback> ExtractCallback; CMyComPtr<IArchiveExtractCallback> ExtractCallback;
#ifndef _NO_PROGRESS CArchiveLink ArchiveLink;
HRESULT Result; HRESULT Result;
UString ErrorMessage;
HRESULT Extract() void Process2()
{ {
return ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), E NFind::CFileInfo fi;
xtractCallback); if (!fi.Find(FileName))
} {
DWORD Process() ErrorMessage = kCantFindArchive;
{ Result = E_FAIL;
ExtractCallbackSpec->ProgressDialog.WaitCreating(); return;
Result = Extract(); }
ExtractCallbackSpec->ProgressDialog.MyClose();
return 0;
}
static DWORD WINAPI MyThreadFunction(void *param)
{
return ((CThreadExtracting *)param)->Process();
}
#endif
};
static const LPCWSTR kCantFindArchive = L"Can not find archive file"; CObjectVector<COpenType> incl;
static const LPCWSTR kCantOpenArchive = L"File is not correct archive"; CIntVector excl;
COpenOptions options;
options.codecs = Codecs;
options.types = &incl;
options.excludedFormats = &excl;
options.filePath = fs2us(FileName);
HRESULT ExtractArchive( Result = ArchiveLink.Open2(options, ExtractCallbackSpec);
const UString &fileName, if (Result != S_OK)
const UString &folderName, {
COpenCallbackGUI *openCallback, ErrorMessage = kCantOpenArchive;
bool showProgress, return;
bool &isCorrupt, }
UString &errorMessage)
{
isCorrupt = false;
NFile::NFind::CFileInfoW archiveFileInfo;
if (!NFile::NFind::FindFile(fileName, archiveFileInfo))
{
errorMessage = kCantFindArchive;
return E_FAIL;
}
CThreadExtracting extracter; FString dirPath = DestFolder;
NName::NormalizeDirPathPrefix(dirPath);
HRESULT result = MyOpenArchive(fileName, extracter.ArchiveLink, openCallback); if (!CreateComplexDir(dirPath))
{
ErrorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
#ifdef LANG
0x02000603,
#endif
fs2us(dirPath));
Result = E_FAIL;
return;
}
if (result != S_OK) ExtractCallbackSpec->Init(ArchiveLink.GetArchive(), dirPath, (UString)"Defau
{ lt", fi.MTime, 0);
errorMessage = kCantOpenArchive;
return result;
}
UString directoryPath = folderName; Result = ArchiveLink.GetArchive()->Extract(0, (UInt32)(Int32)-1 , BoolToInt(
NFile::NName::NormalizeDirPathPrefix(directoryPath); false), ExtractCallback);
}
/* void Process()
UString directoryPath;
{ {
UString fullPath; try
int fileNamePartStartIndex;
if (!NWindows::NFile::NDirectory::MyGetFullPathName(fileName, fullPath, file
NamePartStartIndex))
{ {
MessageBox(NULL, "Error 1329484", "7-Zip", 0); #ifndef _NO_PROGRESS
return E_FAIL; CProgressCloser closer(ExtractCallbackSpec->ProgressDialog);
#endif
Process2();
} }
directoryPath = fullPath.Left(fileNamePartStartIndex); catch(...) { Result = E_FAIL; }
} }
*/
if(!NFile::NDirectory::CreateComplexDirectory(directoryPath)) static THREAD_FUNC_DECL MyThreadFunction(void *param)
{ {
errorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER, ((CThreadExtracting *)param)->Process();
#ifdef LANG return 0;
0x02000603,
#endif
directoryPath);
return E_FAIL;
} }
};
extracter.ExtractCallbackSpec = new CExtractCallbackImp; HRESULT ExtractArchive(CCodecs *codecs, const FString &fileName, const FString &
extracter.ExtractCallback = extracter.ExtractCallbackSpec; destFolder,
bool showProgress, bool &isCorrupt, UString &errorMessage)
{
isCorrupt = false;
CThreadExtracting t;
extracter.ExtractCallbackSpec->Init( t.Codecs = codecs;
extracter.ArchiveLink.GetArchive(), t.FileName = fileName;
directoryPath, L"Default", archiveFileInfo.LastWriteTime, 0); t.DestFolder = destFolder;
t.ExtractCallbackSpec = new CExtractCallbackImp;
t.ExtractCallback = t.ExtractCallbackSpec;
#ifndef _NO_PROGRESS #ifndef _NO_PROGRESS
if (showProgress) if (showProgress)
{ {
CThread thread; t.ExtractCallbackSpec->ProgressDialog.IconID = IDI_ICON;
if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter)) NWindows::CThread thread;
throw 271824; RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &t));
UString title; UString title;
#ifdef LANG LangString(IDS_PROGRESS_EXTRACTING, title);
title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890); t.ExtractCallbackSpec->StartProgressDialog(title, thread);
#else
title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING);
#endif
extracter.ExtractCallbackSpec->StartProgressDialog(title);
result = extracter.Result;
} }
else else
#endif #endif
{ {
result = extracter.Extract(); t.Process2();
} }
errorMessage = extracter.ExtractCallbackSpec->_message;
isCorrupt = extracter.ExtractCallbackSpec->_isCorrupt; errorMessage = t.ErrorMessage;
return result; if (errorMessage.IsEmpty())
errorMessage = t.ExtractCallbackSpec->_message;
isCorrupt = t.ExtractCallbackSpec->_isCorrupt;
return t.Result;
} }
 End of changes. 29 change blocks. 
91 lines changed or deleted 90 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)