1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
////////////////////////////////////////////////////////////////////////////////
// This source file is part of the ZipArchive library source distribution and
// is Copyrighted 2000 - 2007 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
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// For the licensing details refer to the License.txt file.
//
// Web Site: http://www.artpol-software.com
////////////////////////////////////////////////////////////////////////////////
/**
* \file ZipPlatform.h
* ZipPlatform namespace declaration.
*
*/
#if !defined(ZIPARCHIVE_ZIPPLATFORM_DOT_H)
#define ZIPARCHIVE_ZIPPLATFORM_DOT_H
#if _MSC_VER > 1000
#pragma once
#endif
class CZipFileHeader;
class CZipAutoBuffer;
#include "ZipString.h"
#include "ZipPathComponent.h"
#include <sys/types.h>
#include "ZipExport.h"
/**
Includes functions that require system-specific implementation.
*/
namespace ZipPlatform
{
/**
Gets the default case-sensitivity for the current file system.
\return
\c true, if the system is case-sensitive; \c false otherwise.
*/
ZIP_API bool GetSystemCaseSensitivity();
/**
Gets the current system identifier.
\return
One of the ZipCompatibility::ZipPlatforms values.
\see
CZipArchive::SetSystemCompatibility
*/
ZIP_API int GetSystemID();
/**
Gets the default file attributes for the current system.
\return
The default file attributes.
*/
ZIP_API DWORD GetDefaultAttributes();
/**
Gets the default directory attributes for the current system.
\return
The default directory attributes.
*/
ZIP_API DWORD GetDefaultDirAttributes();
/**
Gets the free space on the given device.
\param lpszPath
Points to the device to test.
\return
The free space in bytes.
*/
ZIP_API ULONGLONG GetDeviceFreeSpace(LPCTSTR lpszPath);
/**
Gets 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
space availability is not checked.
*/
ZIP_API CZipString GetTmpFileName(LPCTSTR lpszPath = NULL, ZIP_SIZE_TYPE uSizeNeeded = ZIP_SIZE_TYPE(-1));
/**
\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 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 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 RenameFile( LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow = true); ///< Renames a file.
#ifdef ZIP_ARCHIVE_LNX
ZIP_API bool SetExeAttr( LPCTSTR lpFileName ); ///< Sets executable permissions for a file.
#endif
#if defined ZIP_ARCHIVE_STL || defined ZIP_FILE_USES_STL
/**
Truncates the file.
\note
Defined only in the STL version.
*/
ZIP_API bool TruncateFile(int iDes, ULONGLONG uSize);
/**
Opens the file.
\note
Defined only in the STL version.
*/
ZIP_API int OpenFile(LPCTSTR lpszFileName, UINT iMode, int iShareMode);
/**
Flushes the file to the disk.
\note
Defined only in the STL version.
*/
ZIP_API bool FlushFile(int iDes);
/**
Gets the underlying system handle.
\note
Defined only in the STL version.
*/
ZIP_API intptr_t GetFileSystemHandle(int iDes);
#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.
\param lpszFilePath
The path to the drive. May point to a file path or a directory on the drive.
\return
\c true. if the drive is removable; \c false otherwise.
\note
Implemented only on Windows system, on all others always returns \c true.
*/
ZIP_API bool IsDriveRemovable(LPCTSTR lpszFilePath);
/**
Checks if the given attributes represent a directory.
\param uAttr
The attributes to test.
\return
\c true if the attributes represent a directory; \c false otherwise.
*/
ZIP_API bool IsDirectory(DWORD uAttr);
/**
Performs the translation between ANSI and OEM character sets.
\param buffer
The buffer containing characters to be translated.
\param bAnsiToOem
If \c true, convert ANSI to OEM; if \c false, OEM to ANSI.
*/
ZIP_API void AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem);
/**
Checks if the given file or directory exists.
\param lpszName
The path to the file or directory to test.
\return
One of the following values:
- \c -1 : the given file exists and is a directory
- \c 1 : the given file exists and is a regular file
- \c 0 : there is no such a file
*/
ZIP_API int FileExists(LPCTSTR lpszName);
#ifdef _UNICODE
/**
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.
Does not contain the terminating \c NULL character.
\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, UINT uCodePage);
/**
Converts a multi-byte character string to a wide character string.
\param szIn
The multi-byte character string to convert.
Should not contain 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 CZipAutoBuffer &szIn, CZipString& szOut, UINT uCodePage);
#endif
};
#endif // !defined(ZIPARCHIVE_ZIPPLATFORM_DOT_H)
|