1 // Common/ListFileUtils.cpp
\r
5 #include "MyWindows.h"
\r
6 #include "../Windows/FileIO.h"
\r
8 #include "ListFileUtils.h"
\r
9 #include "StringConvert.h"
\r
10 #include "UTFConvert.h"
\r
12 static const char kQuoteChar = '\"';
\r
13 static void RemoveQuote(UString &s)
\r
15 if (s.Length() >= 2)
\r
16 if (s[0] == kQuoteChar && s[s.Length() - 1] == kQuoteChar)
\r
17 s = s.Mid(1, s.Length() - 2);
\r
20 bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT codePage)
\r
22 NWindows::NFile::NIO::CInFile file;
\r
23 if (!file.Open(fileName))
\r
26 if (!file.GetLength(length))
\r
28 if (length > ((UInt32)1 << 31))
\r
31 char *p = s.GetBuffer((int)length + 1);
\r
33 if (!file.Read(p, (UInt32)length, processed))
\r
35 p[(UInt32)length] = 0;
\r
41 if (codePage == CP_UTF8)
\r
43 if (!ConvertUTF8ToUnicode(s, u))
\r
48 u = MultiByteToUnicodeString(s, codePage);
\r
56 for (int i = 0; i < u.Length(); i++)
\r
59 if (c == L'\n' || c == 0xD)
\r
64 resultStrings.Add(t);
\r
73 resultStrings.Add(t);
\r