1
0
Fork 0

Removed cFile::ReplaceFileNameInvalidChars().

Its only usage in cProtocol18 has been changed to a simple string replace - only the IPv6's colons were causing problems.
This commit is contained in:
Mattes D 2015-01-25 17:06:15 +01:00
parent edce2cbdcf
commit 1b9c0f1030
3 changed files with 3 additions and 27 deletions

View File

@ -453,29 +453,6 @@ AString cFile::ReadWholeFile(const AString & a_FileName)
AString cFile::ReplaceFileNameInvalidChars(const AString & a_FileName, char a_Replacement)
{
AString res(a_FileName);
for (auto & ch: res)
{
switch (ch)
{
case ':':
case '\\':
case '/':
{
ch = a_Replacement;
break;
}
}
}
return res;
}
int cFile::Printf(const char * a_Fmt, ...)
{
AString buf;

View File

@ -127,9 +127,6 @@ public:
/** Returns the entire contents of the specified file as a string. Returns empty string on error. */
static AString ReadWholeFile(const AString & a_FileName);
/** Replaces characters that cannot be in a file name with the specified char. */
static AString ReplaceFileNameInvalidChars(const AString & a_FileName, char a_Replacement = '_');
// tolua_end
/** Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there). */

View File

@ -108,10 +108,12 @@ cProtocol180::cProtocol180(cClientHandle * a_Client, const AString & a_ServerAdd
{
static int sCounter = 0;
cFile::CreateFolder("CommLogs");
AString IP(a_Client->GetIPString());
ReplaceString(IP, ":", "_");
AString FileName = Printf("CommLogs/%x_%d__%s.log",
static_cast<unsigned>(time(nullptr)),
sCounter++,
cFile::ReplaceFileNameInvalidChars(a_Client->GetIPString()).c_str()
IP.c_str()
);
if (!m_CommLogFile.Open(FileName, cFile::fmWrite))
{