mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 10:07:13 -06:00
4.43 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
0ec42ff829
commit
804edc5756
@@ -62,6 +62,16 @@ void MidFree(void *address) throw()
|
||||
::VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
#ifndef MEM_LARGE_PAGES
|
||||
#define _7ZIP_NO_LARGE_PAGES
|
||||
#endif
|
||||
|
||||
// define _7ZIP_NO_LARGE_PAGES if you don't need LARGE_PAGES support
|
||||
// #define _7ZIP_NO_LARGE_PAGES
|
||||
|
||||
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
static SIZE_T g_LargePageSize =
|
||||
#ifdef _WIN64
|
||||
(1 << 21);
|
||||
@@ -70,9 +80,11 @@ static SIZE_T g_LargePageSize =
|
||||
#endif
|
||||
|
||||
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
||||
#endif
|
||||
|
||||
bool SetLargePageSize()
|
||||
{
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||
::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||
if (largePageMinimum == 0)
|
||||
@@ -81,6 +93,7 @@ bool SetLargePageSize()
|
||||
if (size == 0 || (size & (size - 1)) != 0)
|
||||
return false;
|
||||
g_LargePageSize = size;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,6 +106,7 @@ void *BigAlloc(size_t size) throw()
|
||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_NO_LARGE_PAGES
|
||||
if (size >= (1 << 18))
|
||||
{
|
||||
void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
||||
@@ -100,6 +114,7 @@ void *BigAlloc(size_t size) throw()
|
||||
if (res != 0)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
UString sTemp = s;
|
||||
sTemp.Trim();
|
||||
parts.Clear();
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
UString s1, s2;
|
||||
SplitCommandLine(sTemp, s1, s2);
|
||||
@@ -42,7 +42,7 @@ void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
if (!s1.IsEmpty())
|
||||
parts.Add(s1);
|
||||
if (s2.IsEmpty())
|
||||
return;
|
||||
break;
|
||||
sTemp = s2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __COMMON_COMMANDLINEPARSER_H
|
||||
#define __COMMON_COMMANDLINEPARSER_H
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "String.h"
|
||||
|
||||
namespace NCommandLineParser {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base)
|
||||
do
|
||||
{
|
||||
int delta = (int)(value % base);
|
||||
temp[pos++] = (delta < 10) ? ('0' + delta) : ('a' + (delta - 10));
|
||||
temp[pos++] = (char)((delta < 10) ? ('0' + delta) : ('a' + (delta - 10)));
|
||||
value /= base;
|
||||
}
|
||||
while (value != 0);
|
||||
@@ -32,7 +32,7 @@ void ConvertUInt64ToString(UInt64 value, wchar_t *s)
|
||||
int pos = 0;
|
||||
do
|
||||
{
|
||||
temp[pos++] = L'0' + (int)(value % 10);
|
||||
temp[pos++] = (wchar_t)(L'0' + (int)(value % 10));
|
||||
value /= 10;
|
||||
}
|
||||
while (value != 0);
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#include <tchar.h>
|
||||
#include "StdInStream.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// "was declared deprecated" disabling
|
||||
#pragma warning(disable : 4996 )
|
||||
#endif
|
||||
|
||||
static const char kIllegalChar = '\0';
|
||||
static const char kNewLineChar = '\n';
|
||||
|
||||
@@ -40,7 +45,7 @@ CStdInStream::~CStdInStream()
|
||||
AString CStdInStream::ScanStringUntilNewLine()
|
||||
{
|
||||
AString s;
|
||||
while(true)
|
||||
for (;;)
|
||||
{
|
||||
int intChar = GetChar();
|
||||
if(intChar == EOF)
|
||||
@@ -49,9 +54,10 @@ AString CStdInStream::ScanStringUntilNewLine()
|
||||
if (c == kIllegalChar)
|
||||
throw kIllegalCharMessage;
|
||||
if(c == kNewLineChar)
|
||||
return s;
|
||||
break;
|
||||
s += c;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void CStdInStream::ReadToString(AString &resultString)
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// "was declared deprecated" disabling
|
||||
#pragma warning(disable : 4996 )
|
||||
#endif
|
||||
|
||||
static const char kNewLineChar = '\n';
|
||||
|
||||
static const char *kFileOpenMode = "wt";
|
||||
@@ -27,14 +32,15 @@ bool CStdOutStream::Close()
|
||||
{
|
||||
if(!_streamIsOpen)
|
||||
return true;
|
||||
_streamIsOpen = (fclose(_stream) != 0);
|
||||
return !_streamIsOpen;
|
||||
if (fclose(_stream) != 0)
|
||||
return false;
|
||||
_stream = 0;
|
||||
_streamIsOpen = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdOutStream::Flush()
|
||||
{
|
||||
if(!_streamIsOpen)
|
||||
return false;
|
||||
return (fflush(_stream) == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class CStdOutStream
|
||||
bool _streamIsOpen;
|
||||
FILE *_stream;
|
||||
public:
|
||||
CStdOutStream (): _streamIsOpen(false) {};
|
||||
CStdOutStream (): _streamIsOpen(false), _stream(0) {};
|
||||
CStdOutStream (FILE *stream): _streamIsOpen(false), _stream(stream) {};
|
||||
~CStdOutStream ();
|
||||
bool Open(const char *fileName);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "Common/String.h"
|
||||
#include "String.h"
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -19,9 +19,9 @@ wchar_t MyCharUpper(wchar_t c)
|
||||
{
|
||||
if (c == 0)
|
||||
return 0;
|
||||
wchar_t *res = CharUpperW((LPWSTR)(unsigned int)c);
|
||||
wchar_t *res = CharUpperW((LPWSTR)(UINT_PTR)(unsigned int)c);
|
||||
if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return (wchar_t)(unsigned int)res;
|
||||
return (wchar_t)(unsigned int)(UINT_PTR)res;
|
||||
const int kBufferSize = 4;
|
||||
char s[kBufferSize + 1];
|
||||
int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
|
||||
@@ -37,9 +37,9 @@ wchar_t MyCharLower(wchar_t c)
|
||||
{
|
||||
if (c == 0)
|
||||
return 0;
|
||||
wchar_t *res = CharLowerW((LPWSTR)(unsigned int)c);
|
||||
wchar_t *res = CharLowerW((LPWSTR)(UINT_PTR)(unsigned int)c);
|
||||
if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return (wchar_t)(unsigned int)res;
|
||||
return (wchar_t)(unsigned int)(UINT_PTR)res;
|
||||
const int kBufferSize = 4;
|
||||
char s[kBufferSize + 1];
|
||||
int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
|
||||
@@ -133,7 +133,7 @@ wchar_t MyCharUpper(wchar_t c)
|
||||
/*
|
||||
int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c1 = *s1++;
|
||||
wchar_t c2 = *s2++;
|
||||
@@ -151,7 +151,7 @@ int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
|
||||
|
||||
int MyStringCompare(const char *s1, const char *s2)
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
unsigned char c1 = (unsigned char)*s1++;
|
||||
unsigned char c2 = (unsigned char)*s2++;
|
||||
@@ -163,7 +163,7 @@ int MyStringCompare(const char *s1, const char *s2)
|
||||
|
||||
int MyStringCompare(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c1 = *s1++;
|
||||
wchar_t c2 = *s2++;
|
||||
@@ -175,7 +175,7 @@ int MyStringCompare(const wchar_t *s1, const wchar_t *s2)
|
||||
|
||||
int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c1 = *s1++;
|
||||
wchar_t c2 = *s2++;
|
||||
|
||||
@@ -52,7 +52,7 @@ inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
|
||||
{ return CharPrevA(base, p); }
|
||||
|
||||
inline char MyCharUpper(char c)
|
||||
{ return (char)(unsigned int)CharUpperA((LPSTR)(unsigned int)(unsigned char)c); }
|
||||
{ return (char)(unsigned int)(UINT_PTR)CharUpperA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
|
||||
#ifdef _UNICODE
|
||||
inline wchar_t MyCharUpper(wchar_t c)
|
||||
{ return (wchar_t)CharUpperW((LPWSTR)c); }
|
||||
@@ -61,7 +61,7 @@ wchar_t MyCharUpper(wchar_t c);
|
||||
#endif
|
||||
|
||||
inline char MyCharLower(char c)
|
||||
{ return (char)(unsigned int)CharLowerA((LPSTR)(unsigned int)(unsigned char)c); }
|
||||
{ return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); }
|
||||
#ifdef _UNICODE
|
||||
inline wchar_t MyCharLower(wchar_t c)
|
||||
{ return (wchar_t)CharLowerW((LPWSTR)c); }
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
int Find(T c, int startIndex) const
|
||||
{
|
||||
T *p = _chars + startIndex;
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
if (*p == c)
|
||||
return (int)(p - _chars);
|
||||
@@ -403,7 +403,7 @@ public:
|
||||
if (_length == 0)
|
||||
return -1;
|
||||
T *p = _chars + _length - 1;
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
if (*p == c)
|
||||
return (int)(p - _chars);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define __COMMON_STRINGCONVERT_H
|
||||
|
||||
#include "MyWindows.h"
|
||||
#include "Common/String.h"
|
||||
#include "String.h"
|
||||
#include "Types.h"
|
||||
|
||||
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
|
||||
@@ -43,9 +43,9 @@ inline AString GetOemString(const UString &unicodeString)
|
||||
{ return unicodeString;}
|
||||
inline const UString& GetSystemString(const UString &unicodeString)
|
||||
{ return unicodeString;}
|
||||
inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT codePage)
|
||||
inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
|
||||
{ return unicodeString;}
|
||||
inline const UString& GetSystemString(const UString &unicodeString, UINT codePage)
|
||||
inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
|
||||
{ return unicodeString;}
|
||||
inline UString GetSystemString(const AString &multiByteString, UINT codePage)
|
||||
{ return MultiByteToUnicodeString(multiByteString, codePage);}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
UInt64 ConvertStringToUInt64(const char *s, const char **end)
|
||||
{
|
||||
UInt64 result = 0;
|
||||
while(true)
|
||||
for (;;)
|
||||
{
|
||||
char c = *s;
|
||||
if (c < '0' || c > '9')
|
||||
@@ -25,7 +25,7 @@ UInt64 ConvertStringToUInt64(const char *s, const char **end)
|
||||
UInt64 ConvertOctStringToUInt64(const char *s, const char **end)
|
||||
{
|
||||
UInt64 result = 0;
|
||||
while(true)
|
||||
for (;;)
|
||||
{
|
||||
char c = *s;
|
||||
if (c < '0' || c > '7')
|
||||
@@ -44,7 +44,7 @@ UInt64 ConvertOctStringToUInt64(const char *s, const char **end)
|
||||
UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end)
|
||||
{
|
||||
UInt64 result = 0;
|
||||
while(true)
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c = *s;
|
||||
if (c < '0' || c > '9')
|
||||
|
||||
@@ -16,13 +16,14 @@ static bool IsDelimitChar(char c)
|
||||
static AString GetIDString(const char *string, int &finishPos)
|
||||
{
|
||||
AString result;
|
||||
for (finishPos = 0; true; finishPos++)
|
||||
for (finishPos = 0; ; finishPos++)
|
||||
{
|
||||
char c = string[finishPos];
|
||||
if (IsDelimitChar(c) || c == '=')
|
||||
return result;
|
||||
break;
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool WaitNextLine(const AString &string, int &pos)
|
||||
@@ -57,7 +58,7 @@ bool GetTextConfig(const AString &string, CObjectVector<CTextConfigPair> &pairs)
|
||||
/////////////////////
|
||||
// read strings
|
||||
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
if (!SkipSpaces(string, pos))
|
||||
break;
|
||||
@@ -80,7 +81,7 @@ bool GetTextConfig(const AString &string, CObjectVector<CTextConfigPair> &pairs)
|
||||
return false;
|
||||
pos++;
|
||||
AString message;
|
||||
while(true)
|
||||
for (;;)
|
||||
{
|
||||
if (pos >= string.Length())
|
||||
return false;
|
||||
|
||||
@@ -3,17 +3,55 @@
|
||||
#ifndef __COMMON_TYPES_H
|
||||
#define __COMMON_TYPES_H
|
||||
|
||||
#ifndef _7ZIP_BYTE_DEFINED
|
||||
#define _7ZIP_BYTE_DEFINED
|
||||
typedef unsigned char Byte;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_INT16_DEFINED
|
||||
#define _7ZIP_INT16_DEFINED
|
||||
typedef short Int16;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT16_DEFINED
|
||||
#define _7ZIP_UINT16_DEFINED
|
||||
typedef unsigned short UInt16;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_INT32_DEFINED
|
||||
#define _7ZIP_INT32_DEFINED
|
||||
typedef int Int32;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT32_DEFINED
|
||||
#define _7ZIP_UINT32_DEFINED
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#ifndef _7ZIP_INT64_DEFINED
|
||||
#define _7ZIP_INT64_DEFINED
|
||||
typedef __int64 Int64;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT64_DEFINED
|
||||
#define _7ZIP_UINT64_DEFINED
|
||||
typedef unsigned __int64 UInt64;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef _7ZIP_INT64_DEFINED
|
||||
#define _7ZIP_INT64_DEFINED
|
||||
typedef long long int Int64;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT64_DEFINED
|
||||
#define _7ZIP_UINT64_DEFINED
|
||||
typedef unsigned long long int UInt64;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,16 @@
|
||||
#include "Vector.h"
|
||||
|
||||
CBaseRecordVector::~CBaseRecordVector()
|
||||
{ delete []((unsigned char *)_items); }
|
||||
{ Free(); }
|
||||
|
||||
void CBaseRecordVector::Free()
|
||||
{
|
||||
delete []((unsigned char *)_items);
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
_items = 0;
|
||||
}
|
||||
|
||||
void CBaseRecordVector::Clear()
|
||||
{ DeleteFrom(0); }
|
||||
void CBaseRecordVector::DeleteBack()
|
||||
|
||||
@@ -22,11 +22,12 @@ public:
|
||||
CBaseRecordVector(size_t itemSize):
|
||||
_capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
|
||||
virtual ~CBaseRecordVector();
|
||||
void Free();
|
||||
int Size() const { return _size; }
|
||||
bool IsEmpty() const { return (_size == 0); }
|
||||
void Reserve(int newCapacity);
|
||||
virtual void Delete(int index, int num = 1);
|
||||
void Clear();
|
||||
bool IsEmpty() const { return (_size == 0); }
|
||||
void Reserve(int newCapacity);
|
||||
virtual void Delete(int index, int num = 1);
|
||||
void Clear();
|
||||
void DeleteFrom(int index);
|
||||
void DeleteBack();
|
||||
};
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
CRecordVector():CBaseRecordVector(sizeof(T)){};
|
||||
CRecordVector(const CRecordVector &v):
|
||||
CBaseRecordVector(sizeof(T)) { *this = v;}
|
||||
CRecordVector& operator=(const CRecordVector &v)
|
||||
CRecordVector& operator=(const CRecordVector &v)
|
||||
{
|
||||
Clear();
|
||||
return (*this += v);
|
||||
@@ -220,7 +221,7 @@ public:
|
||||
void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
|
||||
{ CPointerVector::Sort(compare, param); }
|
||||
|
||||
static int CompareObjectItems(void *const *a1, void *const *a2, void *param)
|
||||
static int CompareObjectItems(void *const *a1, void *const *a2, void * /* param */)
|
||||
{ return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
|
||||
void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user