diff --git a/r5dev/public/tier0/utility.h b/r5dev/public/tier0/utility.h index 425f4750..db25e910 100644 --- a/r5dev/public/tier0/utility.h +++ b/r5dev/public/tier0/utility.h @@ -33,6 +33,8 @@ string CreateTimedFileName(); string CreateUUID(); void CreateDirectories(string svInput, string* pszOutput = nullptr, bool bWindows = false); +void AppendSlash(string& svInput, const char separator = '\\'); + string ConvertToWinPath(const string& svInput); string ConvertToUnixPath(const string& svInput); diff --git a/r5dev/tier0/utility.cpp b/r5dev/tier0/utility.cpp index eb495ba9..cf7b5698 100644 --- a/r5dev/tier0/utility.cpp +++ b/r5dev/tier0/utility.cpp @@ -409,6 +409,17 @@ void CreateDirectories(string svInput, string* pszOutput, bool bWindows) fs::create_directories(fspPathOut); } +/////////////////////////////////////////////////////////////////////////////// +// For appending a slash at the end of the string if not already present. +void AppendSlash(string& svInput, const char separator) +{ + char lchar = svInput[svInput.size() - 1]; + if (lchar != '\\' && lchar != '/') + { + svInput.push_back(separator); + } +} + /////////////////////////////////////////////////////////////////////////////// // For converting file paths to windows file paths. string ConvertToWinPath(const string& svInput)