This commit is contained in:
Igor Pavlov
2018-12-30 14:01:47 +00:00
committed by Kornel
parent 18dc2b4161
commit 5b2a99c548
113 changed files with 1805 additions and 932 deletions

View File

@@ -25,14 +25,21 @@ static void AddName(UStringVector &strings, UString &s)
strings.Add(s);
}
bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage)
bool ReadNamesFromListFile2(CFSTR fileName, UStringVector &strings, UINT codePage, DWORD &lastError)
{
lastError = 0;
NWindows::NFile::NIO::CInFile file;
if (!file.Open(fileName))
{
lastError = ::GetLastError();
return false;
}
UInt64 fileSize;
if (!file.GetLength(fileSize))
{
lastError = ::GetLastError();
return false;
}
if (fileSize >= ((UInt32)1 << 31) - 32)
return false;
UString u;
@@ -43,7 +50,10 @@ bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage
CByteArr buf((size_t)fileSize);
UInt32 processed;
if (!file.Read(buf, (UInt32)fileSize, processed))
{
lastError = ::GetLastError();
return false;
}
if (processed != fileSize)
return false;
file.Close();
@@ -74,7 +84,10 @@ bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage
char *p = s.GetBuf((unsigned)fileSize);
UInt32 processed;
if (!file.Read(p, (UInt32)fileSize, processed))
{
lastError = ::GetLastError();
return false;
}
if (processed != fileSize)
return false;
file.Close();

View File

@@ -9,6 +9,10 @@
#define MY__CP_UTF16 1200
#define MY__CP_UTF16BE 1201
bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP);
// bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP);
// = CP_OEMCP
bool ReadNamesFromListFile2(CFSTR fileName, UStringVector &strings, UINT codePage,
DWORD &lastError);
#endif

View File

@@ -307,6 +307,7 @@ public:
void ReplaceOneCharAtPos(unsigned pos, char c) { _chars[pos] = c; }
char *GetBuf() { return _chars; }
/* GetBuf(minLen): provides the buffer that can store
at least (minLen) characters and additional null terminator.
9.35: GetBuf doesn't preserve old characters and terminator */