mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-15 00:11:40 -06:00
4.25 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
47f4915611
commit
af1fe52701
@@ -546,7 +546,7 @@ static bool ParseComplexSize(const UString &src, UInt64 &result)
|
||||
const wchar_t *start = s;
|
||||
const wchar_t *end;
|
||||
UInt64 number = ConvertStringToUInt64(start, &end);
|
||||
int numDigits = end - start;
|
||||
int numDigits = (int)(end - start);
|
||||
if (numDigits == 0 || s.Length() > numDigits + 1)
|
||||
return false;
|
||||
if (s.Length() == numDigits)
|
||||
@@ -789,9 +789,13 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
#endif
|
||||
|
||||
CObjectVector<CDirItem> dirItems;
|
||||
UString errorPath;
|
||||
if (EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPath) != S_OK)
|
||||
throw "cannot find archive";
|
||||
{
|
||||
UStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes);
|
||||
if (res != S_OK || errorPaths.Size() > 0)
|
||||
throw "cannot find archive";
|
||||
}
|
||||
UStringVector archivePaths;
|
||||
int i;
|
||||
for (i = 0; i < dirItems.Size(); i++)
|
||||
|
||||
@@ -25,6 +25,7 @@ static LPCWSTR kArchiveMapSwitch = L" -ai#";
|
||||
static LPCWSTR kStopSwitchParsing = L" --";
|
||||
|
||||
|
||||
#ifndef _WIN64
|
||||
static bool IsItWindowsNT()
|
||||
{
|
||||
OSVERSIONINFO versionInfo;
|
||||
@@ -33,6 +34,7 @@ static bool IsItWindowsNT()
|
||||
return false;
|
||||
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT MyCreateProcess(const UString ¶ms,
|
||||
LPCTSTR curDir, bool waitFinish,
|
||||
@@ -82,10 +84,12 @@ static UString Get7zGuiPath()
|
||||
UString folder;
|
||||
if (GetProgramFolderPath(folder))
|
||||
path += folder;
|
||||
path += L"7zG";
|
||||
#ifndef _WIN64
|
||||
if (IsItWindowsNT())
|
||||
path += L"7zgn.exe";
|
||||
else
|
||||
path += L"7zg.exe";
|
||||
path += L"n";
|
||||
#endif
|
||||
path += L".exe";
|
||||
// path += L"7z.exe";
|
||||
return GetQuotedString(path);
|
||||
}
|
||||
|
||||
@@ -29,12 +29,13 @@ void AddDirFileInfo(
|
||||
dirItems.Add(item);
|
||||
}
|
||||
|
||||
static HRESULT EnumerateDirectory(
|
||||
static void EnumerateDirectory(
|
||||
const UString &baseFolderPrefix, // base (disk) prefix for scanning
|
||||
const UString &directory, // additional disk prefix starting from baseFolderPrefix
|
||||
const UString &prefix, // logical prefix
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
NFind::CEnumeratorW enumerator(baseFolderPrefix + directory + wchar_t(kAnyStringWildcard));
|
||||
while (true)
|
||||
@@ -43,28 +44,28 @@ static HRESULT EnumerateDirectory(
|
||||
bool found;
|
||||
if (!enumerator.Next(fileInfo, found))
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = baseFolderPrefix + directory;
|
||||
return error;
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(baseFolderPrefix + directory);
|
||||
return;
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
AddDirFileInfo(prefix, directory + fileInfo.Name, fileInfo, dirItems);
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(EnumerateDirectory(baseFolderPrefix, directory + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
prefix + fileInfo.Name + wchar_t(kDirDelimiter), dirItems, errorPath));
|
||||
EnumerateDirectory(baseFolderPrefix, directory + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
prefix + fileInfo.Name + wchar_t(kDirDelimiter), dirItems, errorPaths, errorCodes);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT EnumerateDirItems(
|
||||
void EnumerateDirItems(
|
||||
const UString &baseFolderPrefix, // base (disk) prefix for scanning
|
||||
const UStringVector &fileNames, // names relative to baseFolderPrefix
|
||||
const UString &archiveNamePrefix,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath)
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
for(int i = 0; i < fileNames.Size(); i++)
|
||||
{
|
||||
@@ -72,19 +73,18 @@ HRESULT EnumerateDirItems(
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (!NFind::FindFile(baseFolderPrefix + fileName, fileInfo))
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = baseFolderPrefix + fileName;
|
||||
return error;
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(baseFolderPrefix + fileName);
|
||||
continue;
|
||||
}
|
||||
AddDirFileInfo(archiveNamePrefix, fileName, fileInfo, dirItems);
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
RINOK(EnumerateDirectory(baseFolderPrefix, fileName + wchar_t(kDirDelimiter),
|
||||
EnumerateDirectory(baseFolderPrefix, fileName + wchar_t(kDirDelimiter),
|
||||
archiveNamePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
dirItems, errorPath));
|
||||
dirItems, errorPaths, errorCodes);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT EnumerateDirItems(
|
||||
@@ -95,7 +95,8 @@ static HRESULT EnumerateDirItems(
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
bool enterToSubFolders,
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath)
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
if (!enterToSubFolders)
|
||||
if (curNode.NeedCheckSubDirs())
|
||||
@@ -130,15 +131,16 @@ static HRESULT EnumerateDirItems(
|
||||
NFind::CFileInfoW fileInfo;
|
||||
if (!NFind::FindFile(fullPath, fileInfo))
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = fullPath;
|
||||
return error;
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(fullPath);
|
||||
continue;
|
||||
}
|
||||
bool isDir = fileInfo.IsDirectory();
|
||||
if (isDir && !item.ForDir || !isDir && !item.ForFile)
|
||||
{
|
||||
errorPath = fullPath;
|
||||
return E_FAIL;
|
||||
errorCodes.Add(E_FAIL);
|
||||
errorPaths.Add(fullPath);
|
||||
continue;
|
||||
}
|
||||
const UString realName = fileInfo.Name;
|
||||
const UString realDiskPath = diskPrefix + realName;
|
||||
@@ -170,7 +172,7 @@ static HRESULT EnumerateDirItems(
|
||||
RINOK(EnumerateDirItems(*nextNode,
|
||||
realDiskPath + wchar_t(kDirDelimiter),
|
||||
archivePrefix + realName + wchar_t(kDirDelimiter),
|
||||
addArchivePrefixNew, dirItems, true, callback, errorPath));
|
||||
addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
|
||||
}
|
||||
for (i = 0; i < curNode.SubNodes.Size(); i++)
|
||||
{
|
||||
@@ -184,19 +186,20 @@ static HRESULT EnumerateDirItems(
|
||||
{
|
||||
if (!nextNode.AreThereIncludeItems())
|
||||
continue;
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = fullPath;
|
||||
return error;
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(fullPath);
|
||||
continue;
|
||||
}
|
||||
if (!fileInfo.IsDirectory())
|
||||
{
|
||||
errorPath = fullPath;
|
||||
return E_FAIL;
|
||||
errorCodes.Add(E_FAIL);
|
||||
errorPaths.Add(fullPath);
|
||||
continue;
|
||||
}
|
||||
RINOK(EnumerateDirItems(nextNode,
|
||||
diskPrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
archivePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
|
||||
UStringVector(), dirItems, false, callback, errorPath));
|
||||
UStringVector(), dirItems, false, callback, errorPaths, errorCodes));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -210,9 +213,9 @@ static HRESULT EnumerateDirItems(
|
||||
bool found;
|
||||
if (!enumerator.Next(fileInfo, found))
|
||||
{
|
||||
HRESULT error = ::GetLastError();
|
||||
errorPath = diskPrefix;
|
||||
return error;
|
||||
errorCodes.Add(::GetLastError());
|
||||
errorPaths.Add(diskPrefix);
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
@@ -253,7 +256,7 @@ static HRESULT EnumerateDirItems(
|
||||
RINOK(EnumerateDirItems(*nextNode,
|
||||
diskPrefix + name + wchar_t(kDirDelimiter),
|
||||
archivePrefix + name + wchar_t(kDirDelimiter),
|
||||
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPath));
|
||||
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPaths, errorCodes));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -262,14 +265,14 @@ HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath)
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes)
|
||||
{
|
||||
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"", UStringVector(), dirItems, false, callback, errorPath));
|
||||
RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", UStringVector(), dirItems, false,
|
||||
callback, errorPaths, errorCodes));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,13 @@ void AddDirFileInfo(
|
||||
CObjectVector<CDirItem> &dirItems);
|
||||
|
||||
|
||||
HRESULT EnumerateDirItems(
|
||||
void EnumerateDirItems(
|
||||
const UString &baseFolderPrefix,
|
||||
const UStringVector &fileNames,
|
||||
const UString &archiveNamePrefix,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
UString &errorPath);
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
struct IEnumDirItemCallback
|
||||
{
|
||||
@@ -32,6 +33,7 @@ HRESULT EnumerateItems(
|
||||
const NWildcard::CCensor &censor,
|
||||
CObjectVector<CDirItem> &dirItems,
|
||||
IEnumDirItemCallback *callback,
|
||||
UString &errorPath);
|
||||
UStringVector &errorPaths,
|
||||
CRecordVector<DWORD> &errorCodes);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -127,9 +127,9 @@ HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName)
|
||||
}
|
||||
|
||||
#ifndef _SFX
|
||||
static inline bool TestSignature(const Byte *p1, const Byte *p2, UInt32 size)
|
||||
static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
|
||||
{
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
if (p1[i] != p2[i])
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,7 @@ void SortStringsToIndices(const UStringVector &strings, CIntVector &indices)
|
||||
void **stringsBase = (void **)pointers[0];
|
||||
qsort(&pointers[0], numItems, sizeof(void *), CompareStrings);
|
||||
for(i = 0; i < numItems; i++)
|
||||
indices.Add((void **)pointers[i] - stringsBase);
|
||||
indices.Add((int)((void **)pointers[i] - stringsBase));
|
||||
}
|
||||
|
||||
void SortStrings(const UStringVector &src, UStringVector &dest)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#include "../../../Common/NewHandler.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -99,7 +99,7 @@ class COutMultiVolStream:
|
||||
public IOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
size_t _streamIndex; // required stream
|
||||
int _streamIndex; // required stream
|
||||
UInt64 _offsetPos; // offset from start of _streamIndex index
|
||||
UInt64 _absPos;
|
||||
UInt64 _length;
|
||||
@@ -142,7 +142,7 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
*processedSize = 0;
|
||||
while(size > 0)
|
||||
{
|
||||
if (_streamIndex >= (size_t)Streams.Size())
|
||||
if (_streamIndex >= Streams.Size())
|
||||
{
|
||||
CSubStreamInfo subStream;
|
||||
|
||||
@@ -694,12 +694,17 @@ HRESULT UpdateArchive(const NWildcard::CCensor &censor,
|
||||
CEnumDirItemUpdateCallback enumCallback;
|
||||
enumCallback.Callback = callback;
|
||||
RINOK(callback->StartScanning());
|
||||
UString errorPath;
|
||||
HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPath);
|
||||
UStringVector errorPaths;
|
||||
CRecordVector<DWORD> errorCodes;
|
||||
HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPaths, errorCodes);
|
||||
for (int i = 0; i < errorPaths.Size(); i++)
|
||||
{
|
||||
RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
|
||||
}
|
||||
if(res != S_OK)
|
||||
{
|
||||
errorInfo.Message = L"Scanning error";
|
||||
errorInfo.FileName = errorPath;
|
||||
// errorInfo.FileName = errorPath;
|
||||
return res;
|
||||
}
|
||||
RINOK(callback->FinishScanning());
|
||||
|
||||
@@ -130,6 +130,8 @@ struct CErrorInfo
|
||||
UString FileName;
|
||||
UString FileName2;
|
||||
UString Message;
|
||||
// UStringVector ErrorPaths;
|
||||
// CRecordVector<DWORD> ErrorCodes;
|
||||
CErrorInfo(): SystemError(0) {};
|
||||
};
|
||||
|
||||
@@ -142,6 +144,7 @@ struct IUpdateCallbackUI2: public IUpdateCallbackUI
|
||||
virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) = 0;
|
||||
|
||||
virtual HRESULT StartScanning() = 0;
|
||||
virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) = 0;
|
||||
virtual HRESULT FinishScanning() = 0;
|
||||
|
||||
virtual HRESULT StartArchive(const wchar_t *name, bool updating) = 0;
|
||||
|
||||
@@ -377,7 +377,7 @@ static bool ReadOption(const TCHAR *value, bool defaultValue)
|
||||
void SaveCascadedMenu(bool show)
|
||||
{ SaveOption(kCascadedMenuValueName, show); }
|
||||
bool ReadCascadedMenu()
|
||||
{ return ReadOption(kCascadedMenuValueName, false); }
|
||||
{ return ReadOption(kCascadedMenuValueName, true); }
|
||||
|
||||
|
||||
static void SaveValue(const TCHAR *value, UInt32 valueToWrite)
|
||||
|
||||
Reference in New Issue
Block a user