mirror of
https://github.com/Xevion/easy7zip.git
synced 2026-01-31 12:24:08 -06:00
4.54 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
051769bbc5
commit
b82f80647d
+30
-42
@@ -5,40 +5,18 @@
|
||||
#include "Lang.h"
|
||||
#include "TextConfig.h"
|
||||
|
||||
#include "StdInStream.h"
|
||||
#include "../Windows/FileIO.h"
|
||||
#include "UTFConvert.h"
|
||||
#include "Defs.h"
|
||||
|
||||
/*
|
||||
static UInt32 HexStringToNumber(const char *string, int &finishPos)
|
||||
static bool HexStringToNumber(const UString &s, UInt32 &value)
|
||||
{
|
||||
UInt32 number = 0;
|
||||
for (finishPos = 0; finishPos < 8; finishPos++)
|
||||
{
|
||||
char c = string[finishPos];
|
||||
int a;
|
||||
if (c >= '0' && c <= '9')
|
||||
a = c - '0';
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
a = 10 + c - 'A';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
a = 10 + c - 'a';
|
||||
else
|
||||
return number;
|
||||
number *= 0x10;
|
||||
number += a;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
*/
|
||||
static bool HexStringToNumber(const UString &string, UInt32 &aResultValue)
|
||||
{
|
||||
aResultValue = 0;
|
||||
if (string.IsEmpty())
|
||||
value = 0;
|
||||
if (s.IsEmpty())
|
||||
return false;
|
||||
for (int i = 0; i < string.Length(); i++)
|
||||
for (int i = 0; i < s.Length(); i++)
|
||||
{
|
||||
wchar_t c = string[i];
|
||||
wchar_t c = s[i];
|
||||
int a;
|
||||
if (c >= L'0' && c <= L'9')
|
||||
a = c - L'0';
|
||||
@@ -48,17 +26,17 @@ static bool HexStringToNumber(const UString &string, UInt32 &aResultValue)
|
||||
a = 10 + c - L'a';
|
||||
else
|
||||
return false;
|
||||
aResultValue *= 0x10;
|
||||
aResultValue += a;
|
||||
value *= 0x10;
|
||||
value += a;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool WaitNextLine(const AString &string, int &pos)
|
||||
static bool WaitNextLine(const AString &s, int &pos)
|
||||
{
|
||||
for (;pos < string.Length(); pos++)
|
||||
if (string[pos] == 0x0A)
|
||||
for (; pos < s.Length(); pos++)
|
||||
if (s[pos] == 0x0A)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -70,19 +48,29 @@ static int CompareLangItems(void *const *elem1, void *const *elem2, void *)
|
||||
return MyCompare(langPair1.Value, langPair2.Value);
|
||||
}
|
||||
|
||||
bool CLang::Open(LPCTSTR fileName)
|
||||
bool CLang::Open(LPCWSTR fileName)
|
||||
{
|
||||
_langPairs.Clear();
|
||||
CStdInStream file;
|
||||
NWindows::NFile::NIO::CInFile file;
|
||||
if (!file.Open(fileName))
|
||||
return false;
|
||||
AString string;
|
||||
file.ReadToString(string);
|
||||
UInt64 length;
|
||||
if (!file.GetLength(length))
|
||||
return false;
|
||||
if (length > (1 << 20))
|
||||
return false;
|
||||
AString s;
|
||||
char *p = s.GetBuffer((int)length + 1);
|
||||
UInt32 processed;
|
||||
if (!file.Read(p, (UInt32)length, processed))
|
||||
return false;
|
||||
p[(UInt32)length] = 0;
|
||||
s.ReleaseBuffer();
|
||||
file.Close();
|
||||
int pos = 0;
|
||||
if (string.Length() >= 3)
|
||||
if (s.Length() >= 3)
|
||||
{
|
||||
if (Byte(string[0]) == 0xEF && Byte(string[1]) == 0xBB && Byte(string[2]) == 0xBF)
|
||||
if (Byte(s[0]) == 0xEF && Byte(s[1]) == 0xBB && Byte(s[2]) == 0xBF)
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
@@ -90,15 +78,15 @@ bool CLang::Open(LPCTSTR fileName)
|
||||
// read header
|
||||
|
||||
AString stringID = ";!@Lang@!UTF-8!";
|
||||
if (string.Mid(pos, stringID.Length()) != stringID)
|
||||
if (s.Mid(pos, stringID.Length()) != stringID)
|
||||
return false;
|
||||
pos += stringID.Length();
|
||||
|
||||
if (!WaitNextLine(string, pos))
|
||||
if (!WaitNextLine(s, pos))
|
||||
return false;
|
||||
|
||||
CObjectVector<CTextConfigPair> pairs;
|
||||
if (!GetTextConfig(string.Mid(pos), pairs))
|
||||
if (!GetTextConfig(s.Mid(pos), pairs))
|
||||
return false;
|
||||
|
||||
_langPairs.Reserve(_langPairs.Size());
|
||||
|
||||
Reference in New Issue
Block a user