mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 20:07:05 -06:00
4.23
This commit is contained in:
committed by
Kornel Lesiński
parent
3c510ba80b
commit
ac2b563958
@@ -719,7 +719,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
|
||||
|
||||
CObjectVector<CDirItem> dirItems;
|
||||
EnumerateItems(archiveWildcardCensor, dirItems, NULL);
|
||||
UString errorPath;
|
||||
if (EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPath) != S_OK)
|
||||
throw "cannot find archive";
|
||||
UStringVector archivePaths;
|
||||
int i;
|
||||
for (i = 0; i < dirItems.Size(); i++)
|
||||
|
||||
@@ -35,7 +35,7 @@ static bool IsItWindowsNT()
|
||||
}
|
||||
|
||||
HRESULT MyCreateProcess(const UString ¶ms,
|
||||
LPCTSTR curDir,
|
||||
LPCTSTR curDir, bool waitFinish,
|
||||
NWindows::NSynchronization::CEvent *event)
|
||||
{
|
||||
STARTUPINFO startupInfo;
|
||||
@@ -57,13 +57,15 @@ HRESULT MyCreateProcess(const UString ¶ms,
|
||||
return ::GetLastError();
|
||||
else
|
||||
{
|
||||
if (event != NULL)
|
||||
::CloseHandle(processInformation.hThread);
|
||||
if (waitFinish)
|
||||
WaitForSingleObject(processInformation.hProcess, INFINITE);
|
||||
else if (event != NULL)
|
||||
{
|
||||
HANDLE handles[] = {processInformation.hProcess, *event };
|
||||
::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]),
|
||||
handles, FALSE, INFINITE);
|
||||
handles, FALSE, INFINITE);
|
||||
}
|
||||
::CloseHandle(processInformation.hThread);
|
||||
::CloseHandle(processInformation.hProcess);
|
||||
}
|
||||
return S_OK;
|
||||
@@ -175,7 +177,8 @@ HRESULT CompressFiles(
|
||||
const UStringVector &names,
|
||||
// const UString &outFolder,
|
||||
bool email,
|
||||
bool showDialog)
|
||||
bool showDialog,
|
||||
bool waitFinish)
|
||||
{
|
||||
/*
|
||||
UString curDir;
|
||||
@@ -281,7 +284,7 @@ HRESULT CompressFiles(
|
||||
CSysString sysCurDir = GetSystemString(curDir);
|
||||
RINOK(MyCreateProcess(params,
|
||||
(sysCurDir.IsEmpty()? 0: (LPCTSTR)sysCurDir),
|
||||
&event));
|
||||
waitFinish, &event));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@@ -310,7 +313,7 @@ static HRESULT ExtractGroupCommand(const UStringVector &archivePaths,
|
||||
CFileMapping fileMapping;
|
||||
NSynchronization::CEvent event;
|
||||
RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2));
|
||||
return MyCreateProcess(params2, 0, &event);
|
||||
return MyCreateProcess(params2, 0, false, &event);
|
||||
}
|
||||
|
||||
HRESULT ExtractArchives(const UStringVector &archivePaths,
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include "Windows/Synchronization.h"
|
||||
|
||||
HRESULT MyCreateProcess(const UString ¶ms,
|
||||
LPCTSTR lpCurrentDirectory,
|
||||
NWindows::NSynchronization::CEvent *event = NULL);
|
||||
LPCTSTR lpCurrentDirectory, bool waitFinish,
|
||||
NWindows::NSynchronization::CEvent *event);
|
||||
HRESULT CompressFiles(
|
||||
const UString &curDir,
|
||||
const UString &archiveName,
|
||||
const UStringVector &names,
|
||||
// const UString &outFolder,
|
||||
bool email, bool showDialog);
|
||||
bool email, bool showDialog, bool waitFinish);
|
||||
|
||||
HRESULT ExtractArchives(
|
||||
const UStringVector &archivePaths,
|
||||
|
||||
@@ -35,7 +35,8 @@ static HRESULT EnumerateDirectory(
|
||||
const UString &baseFolderPrefix,
|
||||
const UString &directory,
|
||||
const UString &prefix,
|
||||
CObjectVector<CDirItem> &dirItems)
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
{
|
||||
NFind::CEnumeratorW enumerator(baseFolderPrefix + directory + wchar_t(kAnyStringWildcard));
|
||||
while (true)
|
||||
@@ -43,7 +44,11 @@ static HRESULT EnumerateDirectory(
|
||||
NFind::CFileInfoW fileInfo;
|
||||
bool found;
|
||||
if (!enumerator.Next(fileInfo, found))
|
||||
return ::GetLastError();
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = baseFolderPrefix + directory;
|
||||
return error;
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
AddDirFileInfo(prefix, directory + fileInfo.Name, fileInfo,
|
||||
@@ -51,7 +56,7 @@ static HRESULT EnumerateDirectory(
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(EnumerateDirectory(baseFolderPrefix, directory + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
prefix + fileInfo.Name + wchar_t(kDirDelimiter), dirItems));
|
||||
prefix + fileInfo.Name + wchar_t(kDirDelimiter), dirItems, errorPath));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -61,7 +66,8 @@ HRESULT EnumerateDirItems(
|
||||
const UString &baseFolderPrefix,
|
||||
const UStringVector &fileNames,
|
||||
const UString &archiveNamePrefix,
|
||||
CObjectVector<CDirItem> &dirItems)
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
{
|
||||
for(int i = 0; i < fileNames.Size(); i++)
|
||||
{
|
||||
@@ -74,7 +80,7 @@ HRESULT EnumerateDirItems(
|
||||
{
|
||||
RINOK(EnumerateDirectory(baseFolderPrefix, fileName + wchar_t(kDirDelimiter),
|
||||
archiveNamePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
dirItems));
|
||||
dirItems, errorPath));
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
@@ -87,7 +93,8 @@ static HRESULT EnumerateDirItems(
|
||||
const UString &addArchivePrefix,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback)
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath)
|
||||
{
|
||||
if (!enterToSubFolders)
|
||||
if (curNode.NeedCheckSubDirs())
|
||||
@@ -100,7 +107,11 @@ static HRESULT EnumerateDirItems(
|
||||
NFind::CFileInfoW fileInfo;
|
||||
bool found;
|
||||
if (!enumerator.Next(fileInfo, found))
|
||||
return ::GetLastError();
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = diskPrefix;
|
||||
return error;
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
|
||||
@@ -140,20 +151,23 @@ static HRESULT EnumerateDirItems(
|
||||
RINOK(EnumerateDirItems(*nextNode,
|
||||
diskPrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
archivePrefixNew, addArchivePrefixNew,
|
||||
dirItems, enterToSubFolders2, callback));
|
||||
dirItems, enterToSubFolders2, callback, errorPath));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT EnumerateItems(const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems, IEnumDirItemCallback *callback)
|
||||
HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath)
|
||||
{
|
||||
for (int i = 0; i < censor.Pairs.Size(); i++)
|
||||
{
|
||||
if (callback)
|
||||
RINOK(callback->CheckBreak());
|
||||
const NWildcard::CPair &pair = censor.Pairs[i];
|
||||
RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", L"", dirItems, false, callback));
|
||||
RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", L"", dirItems, false, callback, errorPath));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ HRESULT EnumerateDirItems(
|
||||
const UString &baseFolderPrefix,
|
||||
const UStringVector &fileNames,
|
||||
const UString &archiveNamePrefix,
|
||||
CObjectVector<CDirItem> &dirItems);
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath);
|
||||
|
||||
struct IEnumDirItemCallback
|
||||
{
|
||||
@@ -27,7 +28,10 @@ struct IEnumDirItemCallback
|
||||
};
|
||||
|
||||
|
||||
HRESULT EnumerateItems(const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems, IEnumDirItemCallback *callback);
|
||||
HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -694,7 +694,14 @@ HRESULT UpdateArchive(const NWildcard::CCensor &censor,
|
||||
CEnumDirItemUpdateCallback enumCallback;
|
||||
enumCallback.Callback = callback;
|
||||
RINOK(callback->StartScanning());
|
||||
RINOK(EnumerateItems(censor, dirItems, &enumCallback));
|
||||
UString errorPath;
|
||||
HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPath);
|
||||
if(res != S_OK)
|
||||
{
|
||||
errorInfo.Message = L"Scanning error";
|
||||
errorInfo.FileName = errorPath;
|
||||
return res;
|
||||
}
|
||||
RINOK(callback->FinishScanning());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user