mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
More ConvertToWinPath/ConvertToUnixPath optimizations
Don't allocate static buffer on the stack, use the result string instead.
This commit is contained in:
parent
5334f31644
commit
e97b4e53b2
@ -309,38 +309,34 @@ string CreateDirectories(string svInput, bool bWindows)
|
|||||||
// For converting filepaths to windows filepaths.
|
// For converting filepaths to windows filepaths.
|
||||||
string ConvertToWinPath(const string& svInput)
|
string ConvertToWinPath(const string& svInput)
|
||||||
{
|
{
|
||||||
char szFilePath[MAX_PATH];
|
string results = svInput;
|
||||||
string results;
|
|
||||||
sprintf_s(szFilePath, MAX_PATH, "%s", svInput.c_str());
|
|
||||||
|
|
||||||
// Flip forward slashes in filepath to windows-style backslash
|
// Flip forward slashes in filepath to windows-style backslash
|
||||||
for (size_t i = 0, len = strlen(szFilePath); i < len; i++)
|
for (size_t i = 0; i < results.size(); i++)
|
||||||
{
|
{
|
||||||
if (szFilePath[i] == '/')
|
if (results[i] == '/')
|
||||||
{
|
{
|
||||||
szFilePath[i] = '\\';
|
results[i] = '\\';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results = szFilePath;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// For converting filepaths to unix filepaths.
|
// For converting filepaths to unix filepaths.
|
||||||
string ConvertToUnixPath(const string& svInput)
|
string ConvertToUnixPath(const string& svInput)
|
||||||
{
|
{
|
||||||
char szFilePath[MAX_PATH];
|
string results = svInput;
|
||||||
string results;
|
|
||||||
sprintf_s(szFilePath, MAX_PATH, "%s", svInput.c_str());
|
|
||||||
|
|
||||||
// Flip windows-style backslashes in filepath to forward slash
|
// Flip windows-style backslashes in filepath to forward slash
|
||||||
for (size_t i = 0, len = strlen(szFilePath); i < len; i++)
|
for (size_t i = 0; i < results.size(); i++)
|
||||||
{
|
{
|
||||||
if (szFilePath[i] == '\\')
|
if (results[i] == '\\')
|
||||||
{
|
{
|
||||||
szFilePath[i] = '/';
|
results[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results = szFilePath;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user