diff options
Diffstat (limited to 'zip/ZipArchive/ZipPlatform.h')
| -rw-r--r-- | zip/ZipArchive/ZipPlatform.h | 122 |
1 files changed, 90 insertions, 32 deletions
diff --git a/zip/ZipArchive/ZipPlatform.h b/zip/ZipArchive/ZipPlatform.h index bb7b7e3..6b6cd64 100644 --- a/zip/ZipArchive/ZipPlatform.h +++ b/zip/ZipArchive/ZipPlatform.h @@ -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
////////////////////////////////////////////////////////////////////////////////
/**
@@ -37,9 +37,20 @@ class CZipAutoBuffer; */
namespace ZipPlatform
{
-
/**
- Gets the default case-sensitivity for the current file system.
+ The mode for deleting files.
+ */
+ enum FileOverwriteMode
+ {
+ fomRegular = 0x00, ///< No special action is taken when overwriting a file.
+ fomRemoveReadOnly = 0x01, ///< The read-only attribute is cleared before overwriting a file.
+ fomOnlyIfNewer = 0x02 ///< The file will be overwritten during extraction, only if the file being extracted is newer.
+#if defined _ZIP_SYSTEM_WIN && defined SHFileOperation
+ ,fomRecycleBin = 0x04 ///< The overwritten file is moved to the Recycle Bin (Windows only).
+#endif
+ };
+ /**
+ Returns the default case-sensitivity for the current file system.
\return
\c true, if the system is case-sensitive; \c false otherwise.
@@ -47,7 +58,7 @@ namespace ZipPlatform ZIP_API bool GetSystemCaseSensitivity();
/**
- Gets the current system identifier.
+ Returns the current system identifier.
\return
One of the ZipCompatibility::ZipPlatforms values.
@@ -58,7 +69,7 @@ namespace ZipPlatform ZIP_API int GetSystemID();
/**
- Gets the default file attributes for the current system.
+ Returns the default file attributes for the current system.
\return
The default file attributes.
@@ -66,7 +77,7 @@ namespace ZipPlatform ZIP_API DWORD GetDefaultAttributes();
/**
- Gets the default directory attributes for the current system.
+ Returns the default directory attributes for the current system.
\return
The default directory attributes.
@@ -74,7 +85,7 @@ namespace ZipPlatform ZIP_API DWORD GetDefaultDirAttributes();
/**
- Gets the free space on the given device.
+ Returns the free space on the given device.
\param lpszPath
Points to the device to test.
@@ -85,40 +96,46 @@ namespace ZipPlatform ZIP_API ULONGLONG GetDeviceFreeSpace(LPCTSTR lpszPath);
/**
- Gets the name of a temporary file ensuring there is enough free space in the destination directory.
+ Returns the name of a temporary file ensuring there is enough free space in the destination directory.
\param lpszPath
The path to the directory to initially create the file in.
\param uSizeNeeded
- The requested free space size in bytes. If set to <code>ZIP_SIZE_TYPE(-1)</code>, the
+ The requested free space size in bytes. If set to <code>0</code>, the
space availability is not checked.
*/
- ZIP_API CZipString GetTmpFileName(LPCTSTR lpszPath = NULL, ZIP_SIZE_TYPE uSizeNeeded = ZIP_SIZE_TYPE(-1));
+ ZIP_API CZipString GetTmpFileName(LPCTSTR lpszPath = NULL, ZIP_SIZE_TYPE uSizeNeeded = 0);
/**
\name Various operations on files and directories.
If the functions returns a \c bool value, then \c true indicates that the operation was successful.
*/
//@{
- ZIP_API bool GetCurrentDirectory(CZipString& sz); ///< Gets the current directory and stores it in \a sz.
+ ZIP_API bool GetCurrentDirectory(CZipString& sz); ///< Returns the current directory and stores it in \a sz.
ZIP_API bool ChangeDirectory(LPCTSTR lpDirectory); ///< Changes the current directory.
ZIP_API bool SetFileAttr(LPCTSTR lpFileName, DWORD uAttr); ///< Sets the file attributes.
- ZIP_API bool GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr); ///< Gets the file attributes.
- ZIP_API bool GetFileModTime(LPCTSTR lpFileName, time_t & ttime); ///< Gets the file modification time.
- ZIP_API bool SetFileModTime(LPCTSTR lpFileName, time_t ttime); ///< Set the file modification time.
- ZIP_API bool GetFileSize(LPCTSTR lpszFileName, ZIP_SIZE_TYPE& dSize); ///< Gets the file size.
- ZIP_API bool CreateDirectory(LPCTSTR lpDirectory); ///< Creates a new directory.
+ ZIP_API bool GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr); ///< Returns the file attributes.
+ ZIP_API bool GetFileTimes(LPCTSTR lpFileName, time_t* tModificationTime, time_t* tCreationTime = NULL, time_t* tLastAccessTime = NULL); ///< Retrieves file times.
+ ZIP_API bool SetFileTimes(LPCTSTR lpFileName, const time_t* tModificationTime, const time_t* tCreationTime = NULL, const time_t* tLastAccessTime = NULL); ///< Sets file times.
+ ZIP_API bool GetFileSize(LPCTSTR lpszFileName, ZIP_SIZE_TYPE& dSize); ///< Returns the file size.
+ ZIP_API bool CreateNewDirectory(LPCTSTR lpDirectory); ///< Creates a new directory.
ZIP_API bool SetVolLabel(LPCTSTR lpszPath, LPCTSTR lpszLabel); ///< Sets a label on a removable device. \c lpszPath may point to a file on the device.
ZIP_API bool ForceDirectory(LPCTSTR lpDirectory); ///< Creates nested directories at once.
- ZIP_API bool RemoveFile(LPCTSTR lpszFileName, bool bThrow = true); ///< Removes a file.
+ ZIP_API bool RemoveFile(LPCTSTR lpszFileName, bool bThrow = true, int iMode = fomRegular); ///< Removes a file.
ZIP_API bool RenameFile( LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow = true); ///< Renames a file.
+ void ConvertTimeToFileTime(const time_t& ttime, ZFILETIME& fileTime); // Converts time from the \c time_t format to the \c FILETIME format.
+ bool ConvertFileTimeToTime(const ZFILETIME& fileTime, time_t& ttime); // Converts time from the \c time_t format to the \c FILETIME format.
-#ifdef ZIP_ARCHIVE_LNX
+#ifdef _ZIP_SYSTEM_LINUX
ZIP_API bool SetExeAttr( LPCTSTR lpFileName ); ///< Sets executable permissions for a file.
#endif
+#ifdef _ZIP_SYSTEM_WIN
+ ZIP_API bool SetFileAttr(HANDLE handle, DWORD uAttr); ///< Sets the file attributes.
+ ZIP_API bool SetFileTimes(HANDLE handle, const time_t* tModificationTime, const time_t* tCreationTime = NULL, const time_t* tLastAccessTime = NULL); ///< Set file times.
+#endif
-#if defined ZIP_ARCHIVE_STL || defined ZIP_FILE_USES_STL
+#if defined _ZIP_IMPL_STL || _ZIP_FILE_IMPLEMENTATION == ZIP_ZFI_STL
/**
Truncates the file.
@@ -144,7 +161,7 @@ namespace ZipPlatform ZIP_API bool FlushFile(int iDes);
/**
- Gets the underlying system handle.
+ Returns the underlying system handle.
\note
Defined only in the STL version.
@@ -153,16 +170,6 @@ namespace ZipPlatform #endif
//@}
- /**
- Checks if the given directory exists.
-
- \param lpszDir
- The directory to test.
-
- \return
- \c true, if \a lpszDir exists; \c false otherwise.
- */
- ZIP_API bool DirectoryExists(LPCTSTR lpszDir);
/**
Checks if the given drive is removable.
@@ -189,6 +196,7 @@ namespace ZipPlatform */
ZIP_API bool IsDirectory(DWORD uAttr);
+
/**
Performs the translation between ANSI and OEM character sets.
@@ -237,6 +245,30 @@ namespace ZipPlatform ZIP_API int WideToMultiByte(LPCWSTR lpszIn, CZipAutoBuffer &szOut, UINT uCodePage);
/**
+ Converts a wide character string to a multi-byte character string.
+
+ \param lpszIn
+ The wide character string to convert.
+
+ \param szOut
+ The buffer to receive the converted string.
+ It contains the terminating \c NULL character depending on the \c bAddNull parameter.
+
+ \param bAddNull
+ If \c true, adds the terminating \c NULL character to the end of the resulting string; \c false otherwise.
+
+ \param uCodePage
+ The code page used in conversion.
+
+ \return
+ The \a szOut buffer length, or \c -1 when not succeeded.
+
+ \note
+ Defined only in the UNICODE version.
+ */
+ ZIP_API int WideToMultiByte(LPCWSTR lpszIn, CZipAutoBuffer &szOut, bool bAddNull, UINT uCodePage);
+
+ /**
Converts a multi-byte character string to a wide character string.
\param szIn
@@ -257,6 +289,32 @@ namespace ZipPlatform Defined only in the UNICODE version.
*/
ZIP_API int MultiByteToWide(const CZipAutoBuffer &szIn, CZipString& szOut, UINT uCodePage);
+
+
+ /**
+ Converts a multi-byte character string to a wide character string.
+
+ \param szIn
+ The multi-byte character string to convert.
+ Should contain the terminating \c NULL character or the size should be specified (not less than 0)
+
+ \param iInSize
+ The size of the string to convert or less than to if the size should be determined (the \c szIn string needs to include the terminating \c NULL character).
+
+ \param szOut
+ Receives the converted string.
+
+ \param uCodePage
+ The code page used in conversion.
+
+ \return
+ The length of the string after the conversion (without the terminating \c NULL character)
+ or \c -1 when the function did not succeed.
+
+ \note
+ Defined only in the UNICODE version.
+ */
+ ZIP_API int MultiByteToWide(const char* szIn, int iInSize, CZipString& szOut, UINT uCodePage);
#endif
};
|
