diff options
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp')
-rw-r--r-- | 3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp | 221 |
1 files changed, 121 insertions, 100 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp index 7d61d14d9d9..f67404479b0 100644 --- a/3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/3rdparty/lzma/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -17,7 +17,7 @@ #include "../../Common/StreamUtils.h" #include "../Common/ExtractingFilePath.h" -#ifndef _SFX +#ifndef Z7_SFX #include "../Common/ZipRegistry.h" #endif @@ -28,7 +28,7 @@ #include "FormatUtils.h" #include "LangUtils.h" #include "OverwriteDialog.h" -#ifndef _NO_CRYPTO +#ifndef Z7_NO_CRYPTO #include "PasswordDialog.h" #endif #include "PropertyName.h" @@ -44,10 +44,11 @@ void CExtractCallbackImp::Init() _lang_Extracting = LangString(IDS_PROGRESS_EXTRACTING); _lang_Testing = LangString(IDS_PROGRESS_TESTING); _lang_Skipping = LangString(IDS_PROGRESS_SKIPPING); + _lang_Reading = "Reading"; NumArchiveErrors = 0; ThereAreMessageErrors = false; - #ifndef _SFX + #ifndef Z7_SFX NumFolders = NumFiles = 0; NeedAddFile = false; #endif @@ -59,29 +60,27 @@ void CExtractCallbackImp::AddError_Message(LPCWSTR s) ProgressDialog->Sync.AddError_Message(s); } -#ifndef _SFX +#ifndef Z7_SFX -STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 - #ifndef _SFX - numFiles - #endif - ) +Z7_COM7F_IMF(CExtractCallbackImp::SetNumFiles(UInt64 numFiles)) { - #ifndef _SFX + #ifdef Z7_SFX + UNUSED_VAR(numFiles) + #else ProgressDialog->Sync.Set_NumFilesTotal(numFiles); - #endif + #endif return S_OK; } #endif -STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) +Z7_COM7F_IMF(CExtractCallbackImp::SetTotal(UInt64 total)) { ProgressDialog->Sync.Set_NumBytesTotal(total); return S_OK; } -STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) +Z7_COM7F_IMF(CExtractCallbackImp::SetCompleted(const UInt64 *value)) { return ProgressDialog->Sync.Set_NumBytesCur(value); } @@ -138,7 +137,7 @@ HRESULT CExtractCallbackImp::Open_Finished() return ProgressDialog->Sync.CheckStop(); } -#ifndef _NO_CRYPTO +#ifndef Z7_NO_CRYPTO HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password) { @@ -167,8 +166,8 @@ void CExtractCallbackImp::Open_Clear_PasswordWasAsked_Flag() #endif -#ifndef _SFX -STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) +#ifndef Z7_SFX +Z7_COM7F_IMF(CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)) { ProgressDialog->Sync.Set_Ratio(inSize, outSize); return S_OK; @@ -176,13 +175,13 @@ STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt6 #endif /* -STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total) +Z7_COM7F_IMF(CExtractCallbackImp::SetTotalFiles(UInt64 total) { ProgressDialog->Sync.SetNumFilesTotal(total); return S_OK; } -STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) +Z7_COM7F_IMF(CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) { if (value != NULL) ProgressDialog->Sync.SetNumFilesCur(*value); @@ -190,10 +189,10 @@ STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) } */ -STDMETHODIMP CExtractCallbackImp::AskOverwrite( +Z7_COM7F_IMF(CExtractCallbackImp::AskOverwrite( const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, - Int32 *answer) + Int32 *answer)) { COverwriteDialog dialog; @@ -222,7 +221,7 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( } -STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 * /* position */) +Z7_COM7F_IMF(CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 * /* position */)) { _isFolder = IntToBool(isFolder); _currentFilePath = name; @@ -233,13 +232,14 @@ STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 is case NArchive::NExtract::NAskMode::kExtract: msg = &_lang_Extracting; break; case NArchive::NExtract::NAskMode::kTest: msg = &_lang_Testing; break; case NArchive::NExtract::NAskMode::kSkip: msg = &_lang_Skipping; break; + case NArchive::NExtract::NAskMode::kReadExternal: msg = &_lang_Reading; break; // default: s = "Unknown operation"; } return ProgressDialog->Sync.Set_Status2(*msg, name, IntToBool(isFolder)); } -STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *s) +Z7_COM7F_IMF(CExtractCallbackImp::MessageError(const wchar_t *s)) { AddError_Message(s); return S_OK; @@ -252,9 +252,9 @@ HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &pa return S_OK; } -#ifndef _SFX +#ifndef Z7_SFX -STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *s) +Z7_COM7F_IMF(CExtractCallbackImp::ShowMessage(const wchar_t *s)) { AddError_Message(s); return S_OK; @@ -262,6 +262,7 @@ STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *s) #endif +void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s); void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s) { s.Empty(); @@ -269,25 +270,33 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam if (opRes == NArchive::NExtract::NOperationResult::kOK) return; + #ifndef Z7_SFX UINT messageID = 0; + #endif UINT id = 0; switch (opRes) { case NArchive::NExtract::NOperationResult::kUnsupportedMethod: + #ifndef Z7_SFX messageID = IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD; + #endif id = IDS_EXTRACT_MSG_UNSUPPORTED_METHOD; break; case NArchive::NExtract::NOperationResult::kDataError: + #ifndef Z7_SFX messageID = encrypted ? IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED: IDS_EXTRACT_MESSAGE_DATA_ERROR; + #endif id = IDS_EXTRACT_MSG_DATA_ERROR; break; case NArchive::NExtract::NOperationResult::kCRCError: + #ifndef Z7_SFX messageID = encrypted ? IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED: IDS_EXTRACT_MESSAGE_CRC_ERROR; + #endif id = IDS_EXTRACT_MSG_CRC_ERROR; break; case NArchive::NExtract::NOperationResult::kUnavailable: @@ -316,18 +325,19 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam } UString msg; - UString msgOld; - #ifndef _SFX + #ifndef Z7_SFX + UString msgOld; + #ifdef Z7_LANG if (id != 0) LangString_OnlyFromLangFile(id, msg); if (messageID != 0 && msg.IsEmpty()) LangString_OnlyFromLangFile(messageID, msgOld); - #endif - + #endif if (msg.IsEmpty() && !msgOld.IsEmpty()) s = MyFormatNew(msgOld, fileName); else + #endif { if (msg.IsEmpty() && id != 0) LangString(id, msg); @@ -335,25 +345,23 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam s += msg; else { - char temp[16]; - ConvertUInt32ToString(opRes, temp); - s.AddAscii("Error #"); - s.AddAscii(temp); + s += "Error #"; + s.Add_UInt32((UInt32)opRes); } if (encrypted && opRes != NArchive::NExtract::NOperationResult::kWrongPassword) { - // s.AddAscii(" : "); + // s += " : "; // AddLangString(s, IDS_EXTRACT_MSG_ENCRYPTED); - s.AddAscii(" : "); + s += " : "; AddLangString(s, IDS_EXTRACT_MSG_WRONG_PSW_GUESS); } - s.AddAscii(" : "); + s += " : "; s += fileName; } } -STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypted) +Z7_COM7F_IMF(CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypted)) { switch (opRes) { @@ -368,7 +376,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypte } } - #ifndef _SFX + #ifndef Z7_SFX if (_isFolder) NumFolders++; else @@ -379,7 +387,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypte return S_OK; } -STDMETHODIMP CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name) +Z7_COM7F_IMF(CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name)) { if (opRes != NArchive::NExtract::NOperationResult::kOK) { @@ -396,8 +404,8 @@ STDMETHODIMP CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypt HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name, bool /* testMode */) { - #ifndef _SFX - RINOK(ProgressDialog->Sync.CheckStop()); + #ifndef Z7_SFX + RINOK(ProgressDialog->Sync.CheckStop()) ProgressDialog->Sync.Set_TitleFileName(name); #endif _currentArchivePath = name; @@ -407,17 +415,17 @@ HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name, bool /* testMode */ HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path) { _currentFilePath = path; - #ifndef _SFX + #ifndef Z7_SFX ProgressDialog->Sync.Set_FilePath(path); #endif return S_OK; } -#ifndef _SFX +#ifndef Z7_SFX -HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path) +Z7_COM7F_IMF(CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)) { - #ifndef _SFX + #ifndef Z7_SFX if (NeedAddFile) NumFiles++; NeedAddFile = true; @@ -451,11 +459,12 @@ static void AddNewLineString(UString &s, const UString &m) s.Add_LF(); } +UString GetOpenArcErrorMessage(UInt32 errorFlags); UString GetOpenArcErrorMessage(UInt32 errorFlags) { UString s; - for (unsigned i = 0; i < ARRAY_SIZE(k_ErrorFlagsIds); i++) + for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_ErrorFlagsIds); i++) { UInt32 f = ((UInt32)1 << i); if ((errorFlags & f) == 0) @@ -466,7 +475,7 @@ UString GetOpenArcErrorMessage(UInt32 errorFlags) continue; if (f == kpv_ErrorFlags_EncryptedHeadersError) { - m.AddAscii(" : "); + m += " : "; AddLangString(m, IDS_EXTRACT_MSG_WRONG_PSW_GUESS); } if (!s.IsEmpty()) @@ -483,7 +492,7 @@ UString GetOpenArcErrorMessage(UInt32 errorFlags) ConvertUInt32ToHex(errorFlags, sz + 2); if (!s.IsEmpty()) s.Add_LF(); - s.AddAscii(sz); + s += sz; } return s; @@ -503,7 +512,7 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er) if (warningFlags != 0) { s += GetNameOfProperty(kpidWarningFlags, L"Warnings"); - s.AddAscii(":"); + s += ":"; s.Add_LF(); AddNewLineString(s, GetOpenArcErrorMessage(warningFlags)); } @@ -511,7 +520,7 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er) if (!er.WarningMessage.IsEmpty()) { s += GetNameOfProperty(kpidWarning, L"Warning"); - s.AddAscii(": "); + s += ": "; s += er.WarningMessage; s.Add_LF(); } @@ -519,12 +528,13 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er) static UString GetBracedType(const wchar_t *type) { - UString s = L'['; + UString s ('['); s += type; - s += L']'; + s += ']'; return s; } +void OpenResult_GUI(UString &s, const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result); void OpenResult_GUI(UString &s, const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result) { FOR_VECTOR (level, arcLink.Arcs) @@ -634,7 +644,9 @@ HRESULT CExtractCallbackImp::ExtractResult(HRESULT result) if (result == S_OK) return result; NumArchiveErrors++; - if (result == E_ABORT || result == ERROR_DISK_FULL) + if (result == E_ABORT + || result == HRESULT_FROM_WIN32(ERROR_DISK_FULL) + ) return result; Add_ArchiveName_Error(); @@ -644,7 +656,7 @@ HRESULT CExtractCallbackImp::ExtractResult(HRESULT result) return S_OK; } -#ifndef _NO_CRYPTO +#ifndef Z7_NO_CRYPTO HRESULT CExtractCallbackImp::SetPassword(const UString &password) { @@ -653,14 +665,14 @@ HRESULT CExtractCallbackImp::SetPassword(const UString &password) return S_OK; } -STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) +Z7_COM7F_IMF(CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)) { PasswordWasAsked = true; if (!PasswordIsDefined) { CPasswordDialog dialog; - #ifndef _SFX - bool showPassword = NExtract::Read_ShowPassword(); + #ifndef Z7_SFX + const bool showPassword = NExtract::Read_ShowPassword(); dialog.ShowPassword = showPassword; #endif ProgressDialog->WaitCreating(); @@ -668,7 +680,7 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) return E_ABORT; Password = dialog.Password; PasswordIsDefined = true; - #ifndef _SFX + #ifndef Z7_SFX if (dialog.ShowPassword != showPassword) NExtract::Save_ShowPassword(dialog.ShowPassword); #endif @@ -678,24 +690,24 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) #endif -#ifndef _SFX +#ifndef Z7_SFX -STDMETHODIMP CExtractCallbackImp::AskWrite( +Z7_COM7F_IMF(CExtractCallbackImp::AskWrite( const wchar_t *srcPath, Int32 srcIsFolder, const FILETIME *srcTime, const UInt64 *srcSize, const wchar_t *destPath, BSTR *destPathResult, - Int32 *writeAnswer) + Int32 *writeAnswer)) { UString destPathResultTemp = destPath; // RINOK(StringToBstr(destPath, destPathResult)); - *destPathResult = 0; + *destPathResult = NULL; *writeAnswer = BoolToInt(false); FString destPathSys = us2fs(destPath); - bool srcIsFolderSpec = IntToBool(srcIsFolder); + const bool srcIsFolderSpec = IntToBool(srcIsFolder); CFileInfo destFileInfo; if (destFileInfo.Find(destPathSys)) @@ -704,7 +716,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( { if (!destFileInfo.IsDir()) { - RINOK(MessageError("can not replace file with folder with same name", destPathSys)); + RINOK(MessageError("Cannot replace file with folder with same name", destPathSys)) return E_ABORT; } *writeAnswer = BoolToInt(false); @@ -713,12 +725,12 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( if (destFileInfo.IsDir()) { - RINOK(MessageError("can not replace folder with file with same name", destPathSys)); + RINOK(MessageError("Cannot replace folder with file with same name", destPathSys)) *writeAnswer = BoolToInt(false); return S_OK; } - switch (OverwriteMode) + switch ((int)OverwriteMode) { case NExtract::NOverwriteMode::kSkip: return S_OK; @@ -726,8 +738,8 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( { Int32 overwriteResult; UString destPathSpec = destPath; - int slashPos = destPathSpec.ReverseFind_PathSepar(); - destPathSpec.DeleteFrom(slashPos + 1); + const int slashPos = destPathSpec.ReverseFind_PathSepar(); + destPathSpec.DeleteFrom((unsigned)(slashPos + 1)); destPathSpec += fs2us(destFileInfo.Name); RINOK(AskOverwrite( @@ -735,7 +747,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( &destFileInfo.MTime, &destFileInfo.Size, srcPath, srcTime, srcSize, - &overwriteResult)); + &overwriteResult)) switch (overwriteResult) { @@ -748,31 +760,38 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( default: return E_FAIL; } + break; } + default: + break; } if (OverwriteMode == NExtract::NOverwriteMode::kRename) { if (!AutoRenamePath(destPathSys)) { - RINOK(MessageError("can not create name for file", destPathSys)); + RINOK(MessageError("Cannot create name for file", destPathSys)) return E_ABORT; } destPathResultTemp = fs2us(destPathSys); } else + { + if (NFind::DoesFileExist_Raw(destPathSys)) if (!NDir::DeleteFileAlways(destPathSys)) + if (GetLastError() != ERROR_FILE_NOT_FOUND) { - RINOK(MessageError("can not delete output file", destPathSys)); + RINOK(MessageError("Cannot delete output file", destPathSys)) return E_ABORT; } + } } *writeAnswer = BoolToInt(true); return StringToBstr(destPathResultTemp, destPathResult); } -STDMETHODIMP CExtractCallbackImp::UseExtractToStream(Int32 *res) +Z7_COM7F_IMF(CExtractCallbackImp::UseExtractToStream(Int32 *res)) { *res = BoolToInt(StreamMode); return S_OK; @@ -782,7 +801,7 @@ static HRESULT GetTime(IGetProp *getProp, PROPID propID, FILETIME &ft, bool &ftD { ftDefined = false; NCOM::CPropVariant prop; - RINOK(getProp->GetProp(propID, &prop)); + RINOK(getProp->GetProp(propID, &prop)) if (prop.vt == VT_FILETIME) { ft = prop.filetime; @@ -798,7 +817,7 @@ static HRESULT GetItemBoolProp(IGetProp *getProp, PROPID propID, bool &result) { NCOM::CPropVariant prop; result = false; - RINOK(getProp->GetProp(propID, &prop)); + RINOK(getProp->GetProp(propID, &prop)) if (prop.vt == VT_BOOL) result = VARIANT_BOOLToBool(prop.boolVal); else if (prop.vt != VT_EMPTY) @@ -807,13 +826,13 @@ static HRESULT GetItemBoolProp(IGetProp *getProp, PROPID propID, bool &result) } -STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, +Z7_COM7F_IMF(CExtractCallbackImp::GetStream7(const wchar_t *name, Int32 isDir, ISequentialOutStream **outStream, Int32 askExtractMode, - IGetProp *getProp) + IGetProp *getProp)) { COM_TRY_BEGIN - *outStream = 0; + *outStream = NULL; _newVirtFileWasAdded = false; _hashStreamWasUsed = false; _needUpdateStat = false; @@ -829,20 +848,20 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, _filePath = name; _isFolder = IntToBool(isDir); _curSize = 0; - _curSizeDefined = false; + _curSize_Defined = false; UInt64 size = 0; bool sizeDefined; { NCOM::CPropVariant prop; - RINOK(getProp->GetProp(kpidSize, &prop)); + RINOK(getProp->GetProp(kpidSize, &prop)) sizeDefined = ConvertPropVariantToUInt64(prop, size); } if (sizeDefined) { _curSize = size; - _curSizeDefined = true; + _curSize_Defined = true; } if (askExtractMode != NArchive::NExtract::NAskMode::kExtract && @@ -862,12 +881,12 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, file.IsAltStream = _isAltStream; file.Size = 0; - RINOK(GetTime(getProp, kpidCTime, file.CTime, file.CTimeDefined)); - RINOK(GetTime(getProp, kpidATime, file.ATime, file.ATimeDefined)); - RINOK(GetTime(getProp, kpidMTime, file.MTime, file.MTimeDefined)); + RINOK(GetTime(getProp, kpidCTime, file.CTime, file.CTimeDefined)) + RINOK(GetTime(getProp, kpidATime, file.ATime, file.ATimeDefined)) + RINOK(GetTime(getProp, kpidMTime, file.MTime, file.MTimeDefined)) NCOM::CPropVariant prop; - RINOK(getProp->GetProp(kpidAttrib, &prop)); + RINOK(getProp->GetProp(kpidAttrib, &prop)) if (prop.vt == VT_UI4) { file.Attrib = prop.ulVal; @@ -897,12 +916,14 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, COM_TRY_END } -STDMETHODIMP CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode) +Z7_COM7F_IMF(CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode)) { COM_TRY_BEGIN _needUpdateStat = ( - askExtractMode == NArchive::NExtract::NAskMode::kExtract || - askExtractMode == NArchive::NExtract::NAskMode::kTest); + askExtractMode == NArchive::NExtract::NAskMode::kExtract + || askExtractMode == NArchive::NExtract::NAskMode::kTest + || askExtractMode == NArchive::NExtract::NAskMode::kReadExternal + ); /* _extractMode = false; @@ -920,27 +941,27 @@ STDMETHODIMP CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode) COM_TRY_END } -STDMETHODIMP CExtractCallbackImp::SetOperationResult7(Int32 opRes, Int32 encrypted) +Z7_COM7F_IMF(CExtractCallbackImp::SetOperationResult8(Int32 opRes, Int32 encrypted, UInt64 size)) { COM_TRY_BEGIN if (VirtFileSystem && _newVirtFileWasAdded) { // FIXME: probably we must request file size from VirtFileSystem // _curSize = VirtFileSystem->GetLastFileSize() - // _curSizeDefined = true; - RINOK(VirtFileSystemSpec->CloseMemFile()); + // _curSize_Defined = true; + RINOK(VirtFileSystemSpec->CloseMemFile()) } if (_hashStream && _hashStreamWasUsed) { _hashStreamSpec->_hash->Final(_isFolder, _isAltStream, _filePath); _curSize = _hashStreamSpec->GetSize(); - _curSizeDefined = true; + _curSize_Defined = true; _hashStreamSpec->ReleaseStream(); _hashStreamWasUsed = false; } else if (_hashCalc && _needUpdateStat) { - _hashCalc->SetSize(_curSize); + _hashCalc->SetSize(size); // (_curSize) before 21.04 _hashCalc->Final(_isFolder, _isAltStream, _filePath); } return SetOperationResult(opRes, encrypted); @@ -948,11 +969,10 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult7(Int32 opRes, Int32 encrypt } -static const size_t k_SizeT_MAX = (size_t)((size_t)0 - 1); -static const UInt32 kBlockSize = ((UInt32)1 << 31); +// static const UInt32 kBlockSize = ((UInt32)1 << 31); -STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize) +Z7_COM7F_IMF(CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize)) { if (processedSize) *processedSize = 0; @@ -975,8 +995,9 @@ STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *proce if (b < a) b = a; useMem = false; - if (b <= k_SizeT_MAX && b <= MaxTotalAllocSize) - useMem = file.Data.ReAlloc_KeepData((size_t)b, (size_t)file.Size); + const size_t b_sizet = (size_t)b; + if (b == b_sizet && b <= MaxTotalAllocSize) + useMem = file.Data.ReAlloc_KeepData(b_sizet, (size_t)file.Size); } if (useMem) { @@ -988,7 +1009,7 @@ STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *proce } _fileMode = true; } - RINOK(FlushToDisk(false)); + RINOK(FlushToDisk(false)) return _outFileStream->Write(data, size, processedSize); } @@ -1009,10 +1030,10 @@ HRESULT CVirtFileSystem::FlushToDisk(bool closeLast) { _outFileStream.Release(); return E_FAIL; - // MessageBoxMyError(UString(L"Can't create file ") + fs2us(tempFilePath)); + // MessageBoxMyError(UString("Can't create file ") + fs2us(tempFilePath)); } _fileIsOpen = true; - RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size)); + RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size)) } if (_numFlushed == Files.Size() - 1 && !closeLast) break; @@ -1027,7 +1048,7 @@ HRESULT CVirtFileSystem::FlushToDisk(bool closeLast) _numFlushed++; _fileIsOpen = false; if (file.AttribDefined) - NDir::SetFileAttrib(path, file.Attrib); + NDir::SetFileAttrib_PosixHighDetect(path, file.Attrib); } return S_OK; } |