Files
harbour-core/harbour/contrib/hbziparch/ZipFile_stl.h
Viktor Szakats 40338a87d6 2008-06-24 00:35 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbziparch/_features.h
   * contrib/hbziparch/_platform.h
   * contrib/hbziparch/Aes.cpp
   * contrib/hbziparch/Aes.h
   * contrib/hbziparch/BaseLibCompressor.cpp
   * contrib/hbziparch/BaseLibCompressor.h
   * contrib/hbziparch/BytesWriter.h
   * contrib/hbziparch/Bzip2Compressor.cpp
   * contrib/hbziparch/Bzip2Compressor.h
   * contrib/hbziparch/DeflateCompressor.cpp
   * contrib/hbziparch/DeflateCompressor.h
   * contrib/hbziparch/DirEnumerator.cpp
   * contrib/hbziparch/DirEnumerator.h
   * contrib/hbziparch/FileFilter.cpp
   * contrib/hbziparch/FileFilter.h
   * contrib/hbziparch/FileInfo.h
   * contrib/hbziparch/Hmac.cpp
   * contrib/hbziparch/Hmac.h
   * contrib/hbziparch/RandomPool.cpp
   * contrib/hbziparch/RandomPool.h
   * contrib/hbziparch/Sha1.cpp
   * contrib/hbziparch/Sha1.h
   * contrib/hbziparch/std_mfc.h
   * contrib/hbziparch/std_stl.h
   * contrib/hbziparch/Wildcard.cpp
   * contrib/hbziparch/Wildcard.h
   * contrib/hbziparch/ZipAbstractFile.h
   * contrib/hbziparch/ZipAesCryptograph.cpp
   * contrib/hbziparch/ZipAesCryptograph.h
   * contrib/hbziparch/ZipArchive.cpp
   * contrib/hbziparch/ZipArchive.h
   * contrib/hbziparch/ZipAutoBuffer.cpp
   * contrib/hbziparch/ZipAutoBuffer.h
   * contrib/hbziparch/ZipBaseException.h
   * contrib/hbziparch/ZipCallback.h
   * contrib/hbziparch/ZipCallbackProvider.h
   * contrib/hbziparch/ZipCentralDir.cpp
   * contrib/hbziparch/ZipCentralDir.h
   * contrib/hbziparch/ZipCollections.h
   * contrib/hbziparch/ZipCollections_mfc.h
   * contrib/hbziparch/ZipCollections_stl.h
   * contrib/hbziparch/ZipCompatibility.cpp
   * contrib/hbziparch/ZipCompatibility.h
   * contrib/hbziparch/ZipCompressor.cpp
   * contrib/hbziparch/ZipCompressor.h
   * contrib/hbziparch/ZipCrc32Cryptograph.cpp
   * contrib/hbziparch/ZipCrc32Cryptograph.h
   * contrib/hbziparch/ZipCryptograph.cpp
   * contrib/hbziparch/ZipCryptograph.h
   * contrib/hbziparch/ZipException.cpp
   * contrib/hbziparch/ZipException.h
   * contrib/hbziparch/ZipExtraData.cpp
   * contrib/hbziparch/ZipExtraData.h
   * contrib/hbziparch/ZipExtraField.cpp
   * contrib/hbziparch/ZipExtraField.h
   * contrib/hbziparch/ZipFile.h
   * contrib/hbziparch/ZipFile_mfc.cpp
   * contrib/hbziparch/ZipFile_mfc.h
   * contrib/hbziparch/ZipFile_stl.cpp
   * contrib/hbziparch/ZipFile_stl.h
   * contrib/hbziparch/ZipFileHeader.cpp
   * contrib/hbziparch/ZipFileHeader.h
   * contrib/hbziparch/ZipFileMapping.h
   * contrib/hbziparch/ZipFileMapping_lnx.h
   * contrib/hbziparch/ZipFileMapping_win.h
   * contrib/hbziparch/ZipMemFile.cpp
   * contrib/hbziparch/ZipMemFile.h
   * contrib/hbziparch/ZipMutex.h
   * contrib/hbziparch/ZipMutex_lnx.h
   * contrib/hbziparch/ZipMutex_win.h
   * contrib/hbziparch/ZipPathComponent.h
   * contrib/hbziparch/ZipPlatform.h
   * contrib/hbziparch/ZipPlatformComm.cpp
   * contrib/hbziparch/ZipStorage.cpp
   * contrib/hbziparch/ZipStorage.h
   * contrib/hbziparch/ZipString.h
   * contrib/hbziparch/ZipString_mfc.h
   * contrib/hbziparch/ZipString_stl.h
   * contrib/hbziparch/ZipStringStoreSettings.h
     + ZipArchive lib update finished.
     ; Pass 2/2
     ; Please test.
2008-06-23 22:41:33 +00:00

120 lines
2.7 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// 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
////////////////////////////////////////////////////////////////////////////////
#ifndef ZIPARCHIVE_ZIPFILE_DOT_H
#error Do not include this file directly. Include ZipFile.h instead
#endif
#include "ZipAbstractFile.h"
#include "ZipString.h"
#include "ZipExport.h"
#ifndef __GNUC__
#include <io.h>
#else
#include <unistd.h>
#include <errno.h>
#endif
#if !defined (_MSC_VER) || _MSC_VER < 1400
// there seems to be a problem under Windows sometimes when using one of the functions below
// without the underscore at the beginning
#ifndef _lseek
#define _lseek lseek
#endif
#ifndef _read
#define _read read
#endif
#ifndef _close
#define _close close
#endif
#ifndef _tell
#define _tell tell
#endif
#ifndef _write
#define _write write
#endif
#endif
class ZIP_API CZipFile : public CZipAbstractFile
{
void ThrowError() const;
public:
int m_hFile;
operator HANDLE();
enum OpenModes
{
modeRead = 0x0001,
modeWrite = 0x0002,
modeReadWrite = modeRead | modeWrite,
shareDenyWrite = 0x0004,
shareDenyRead = 0x0008,
shareDenyNone = 0x0010,
modeCreate = 0x0020,
modeNoTruncate = 0x0040,
};
CZipFile(LPCTSTR lpszFileName, UINT openFlags)
{
m_hFile = -1;
Open(lpszFileName, openFlags, true);
}
void Flush();
ZIP_FILE_USIZE GetLength() const;
CZipString GetFilePath() const {return m_szFileName;}
bool IsClosed()const { return m_hFile == -1;}
bool Open(LPCTSTR lpszFileName, UINT openFlags, bool bThrow);
void Close()
{
if (IsClosed())
return;
if (_close(m_hFile) != 0)
ThrowError();
else
{
m_szFileName.Empty();
m_hFile = -1;
}
}
void Write(const void* lpBuf, UINT nCount)
{
if (_write(m_hFile, lpBuf, nCount) != (int) nCount)
ThrowError();
}
ZIP_FILE_USIZE GetPosition() const;
void SetLength(ZIP_FILE_USIZE uNewLen);
UINT Read(void *lpBuf, UINT nCount)
{
errno = 0;
int ret = _read(m_hFile, lpBuf, nCount);
if (ret < (int) nCount && errno != 0)
ThrowError();
return ret;
}
ZIP_FILE_USIZE Seek(ZIP_FILE_SIZE dOff, int nFrom);
CZipFile ();
virtual ~CZipFile (){Close();};
protected:
CZipString m_szFileName;
};