From 02d6107c97b48888362e7c6a70dcac323c89d741 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 17 Dec 2023 21:23:58 +0100 Subject: ZipArchive: Update to the 4.6.9 release --- zip/ZipArchive/ZipException.cpp | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'zip/ZipArchive/ZipException.cpp') diff --git a/zip/ZipArchive/ZipException.cpp b/zip/ZipArchive/ZipException.cpp index eed1e46..42d6cbc 100644 --- a/zip/ZipArchive/ZipException.cpp +++ b/zip/ZipArchive/ZipException.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyrighted 2000 - 2007 by Artpol Software - Tadeusz Dracz +// This source file is part of the ZipArchive Library Open Source distribution +// and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -9,7 +9,7 @@ // // For the licensing details refer to the License.txt file. // -// Web Site: http://www.artpol-software.com +// Web Site: https://www.artpol-software.com //////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" @@ -20,7 +20,7 @@ ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// -#if defined _MFC_VER && defined ZIP_ARCHIVE_MFC +#if defined _MFC_VER && defined _ZIP_IMPL_MFC IMPLEMENT_DYNAMIC( CZipException, CException) #endif @@ -32,10 +32,16 @@ CZipException::CZipException(int iCause, LPCTSTR lpszZipName) m_iCause = iCause; if (lpszZipName) - m_szFileName = lpszZipName; + m_szFileName = lpszZipName; + +#ifdef _ZIP_SYSTEM_WIN + m_iSystemError = ::GetLastError(); +#else + m_iSystemError = errno; +#endif } -CZipException::~CZipException() throw() +CZipException::~CZipException() _NOEXCEPT { } @@ -53,7 +59,7 @@ CZipException::~CZipException() throw() // } -#ifdef ZIP_ENABLE_ERROR_DESCRIPTION +#ifdef _ZIP_ENABLE_ERROR_DESCRIPTION ZBOOL CZipException::GetErrorMessage(LPTSTR lpszError, UINT nMaxError, UINT* ) @@ -95,13 +101,12 @@ CZipString CZipException::GetErrorDescription() CZipString CZipException::GetSystemErrorDescription() { -#ifdef WIN32 - DWORD x = GetLastError(); - if (x) +#ifdef WIN32 + if (m_iSystemError) { LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, x, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + NULL, m_iSystemError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL); CZipString sz = (LPCTSTR)lpMsgBuf; LocalFree(lpMsgBuf); @@ -188,6 +193,9 @@ CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) case noCallback: sz = _T("There is no spanned archive callback object set."); break; + case noVolumeSize: + sz = _T("The volume size was not defined for a split archive."); + break; case aborted: sz = _T("Volume change aborted in a segmented archive."); break; @@ -201,13 +209,13 @@ CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) sz = _T("The device selected for the spanned archive is not removable."); break; case tooManyVolumes: - sz = _T("The limit of the maximum volumes reached."); + sz = _T("The limit of the maximum number of volumes has been reached."); break; case tooManyFiles: - sz = _T("The limit of the maximum files in an archive reached."); + sz = _T("The limit of the maximum number of files in an archive has been reached."); break; case tooLongData: - sz = _T("The filename, the comment or the local or central extra field of the file added to the archive is too long."); + sz = _T("The filename, the comment or local or central extra field of the file added to the archive is too long."); break; case tooBigSize: sz = _T("The file size is too large to be supported."); @@ -221,6 +229,9 @@ CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) case internalError: sz = _T("An internal error."); break; + case fileError: + sz.Format(_T("%s (%s)."), _T("A file error occurred"), (LPCTSTR)GetSystemErrorDescription()); + break; case notRemoved: sz.Format(_T("%s (%s)."), _T("Error while removing a file"), (LPCTSTR)GetSystemErrorDescription()); break; @@ -239,12 +250,12 @@ CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) case noAES: sz = _T("WinZip AES encryption has not been enabled for the library, but is required to decompress the archive."); break; -#ifdef ZIP_ARCHIVE_STL +#ifdef _ZIP_IMPL_STL case outOfBounds: sz = _T("The collection is empty and the bounds do not exist."); break; #endif -#ifdef ZIP_ARCHIVE_USE_LOCKING +#ifdef _ZIP_USE_LOCKING case mutexError: sz = _T("Locking or unlocking resources access was unsuccessful."); break; @@ -271,9 +282,9 @@ CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) sz = _T("Zlib library error (version error)."); break; default: - sz = bNoLoop ? _T("Unknown error") :(LPCTSTR) GetSystemErrorDescription(); + sz = bNoLoop ? _T("Unspecified error") :(LPCTSTR) GetSystemErrorDescription(); } return sz; } -#endif //ZIP_ENABLE_ERROR_DESCRIPTION +#endif //_ZIP_ENABLE_ERROR_DESCRIPTION -- cgit v1.2.3