cFile: Added ReplaceFileNameInvalidChars().
This commit is contained in:
parent
7cff25f0ff
commit
f1f12495b2
@ -453,6 +453,29 @@ 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, ...)
|
int cFile::Printf(const char * a_Fmt, ...)
|
||||||
{
|
{
|
||||||
AString buf;
|
AString buf;
|
||||||
|
@ -126,6 +126,9 @@ public:
|
|||||||
|
|
||||||
/** Returns the entire contents of the specified file as a string. Returns empty string on error. */
|
/** Returns the entire contents of the specified file as a string. Returns empty string on error. */
|
||||||
static AString ReadWholeFile(const AString & a_FileName);
|
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
|
// tolua_end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user