diff --git a/Common/cfcpp/Stream/fstream_wrapper.h b/Common/cfcpp/Stream/fstream_wrapper.h index 0e4087cb31..58676381db 100644 --- a/Common/cfcpp/Stream/fstream_wrapper.h +++ b/Common/cfcpp/Stream/fstream_wrapper.h @@ -68,6 +68,9 @@ public: inline void close() override { std::fstream::close(); } + inline bool isError() override { + return (std::fstream::bad() || std::fstream::fail()); + } }; } diff --git a/Common/cfcpp/Stream/stream.h b/Common/cfcpp/Stream/stream.h index e773959cbd..dfd4431ae0 100644 --- a/Common/cfcpp/Stream/stream.h +++ b/Common/cfcpp/Stream/stream.h @@ -48,6 +48,7 @@ namespace CFCPP virtual void write (const char* buffer, _INT64 len) = 0; virtual void flush() = 0; virtual void close() = 0; + virtual bool isError() = 0; }; using Stream = std::shared_ptr; diff --git a/Common/cfcpp/streamview.cpp b/Common/cfcpp/streamview.cpp index b38c2039bf..3b80feef55 100644 --- a/Common/cfcpp/streamview.cpp +++ b/Common/cfcpp/streamview.cpp @@ -123,6 +123,14 @@ void StreamView::close() if (std::dynamic_pointer_cast(stream) != nullptr) stream->close(); } +bool StreamView::isError() +{ + if (std::dynamic_pointer_cast(stream) == nullptr) return true; + if ((std::dynamic_pointer_cast(stream))->bad()) return true; + if ((std::dynamic_pointer_cast(stream))->fail()) return true; + + return false; +} _INT64 StreamView::read(char *buffer, _INT64 len) { diff --git a/Common/cfcpp/streamview.h b/Common/cfcpp/streamview.h index 6a8786cd05..94d5cd1c37 100644 --- a/Common/cfcpp/streamview.h +++ b/Common/cfcpp/streamview.h @@ -46,14 +46,13 @@ public: StreamView(const SVector §orChain, _INT32 sectorSize, _INT64 length, SList &availableSectors, Stream stream, bool isFatStream = false); - _INT64 tell() override; _INT64 seek(_INT64 offset, std::ios_base::seekdir mode = std::ios::beg) override; _INT64 read(char *buffer, _INT64 count) override; void write(const char *buffer, _INT64 count) override; void flush() override {} void close() override; - + bool isError() override; _INT64 getPosition() const; void SetLength(_INT64 value); diff --git a/OfficeCryptReader/source/ECMACryptFile.cpp b/OfficeCryptReader/source/ECMACryptFile.cpp index d320169d55..8f5384d171 100644 --- a/OfficeCryptReader/source/ECMACryptFile.cpp +++ b/OfficeCryptReader/source/ECMACryptFile.cpp @@ -942,9 +942,10 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s } } //------------------------------------------------------------------- + bool result = true; if (bLargeFile) { - pStorageNew->Save(file_name_out); + result = pStorageNew->Save(file_name_out); pStorageNew->Close(); delete pStorageNew; } @@ -974,7 +975,7 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s // } ////test back---------------------------------------------------------------------------------test back - return true; + return result; } bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity) { diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 89b7cac483..14ec6e0994 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -3049,11 +3049,12 @@ namespace NExtractTools NSDirectory::CreateDirectory(sTempUnpackedOox); _UINT32 nRes = odf_flat2oox_dir(sFrom, sTempUnpackedOox, sTemp, params); - if(SUCCEEDED_X2T(nRes)) - { - COfficeUtils oCOfficeUtils(NULL); - nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedOox, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - } + + if (SUCCEEDED_X2T(nRes)) + { + nRes = dir2zipMscrypt(sTempUnpackedOox, sTo, sTemp, params); + } + return nRes; } _UINT32 odf_flat2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)