linux fixes

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-03 17:59:35 -07:00
parent cbfdf99a9e
commit e28602dbbb
42 changed files with 186 additions and 225 deletions
+4 -4
View File
@@ -221,7 +221,7 @@ inline CCryFile::~CCryFile()
inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlagsEx)
{
char tempfilename[CRYFILE_MAX_PATH] = "";
azstrcpy(tempfilename, filename);
azstrcpy(tempfilename, CRYFILE_MAX_PATH, filename);
#if !defined (_RELEASE)
if (gEnv && gEnv->IsEditor() && gEnv->pConsole)
@@ -233,7 +233,7 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag
if (lowercasePaths)
{
const AZStd::string lowerString = PathUtil::ToLower(tempfilename);
azstrcpy(tempfilename, lowerString.c_str());
azstrcpy(tempfilename, CRYFILE_MAX_PATH, lowerString.c_str());
}
}
}
@@ -242,7 +242,7 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag
{
Close();
}
azstrcpy(m_filename, tempfilename);
azstrcpy(m_filename, CRYFILE_MAX_PATH, tempfilename);
if (m_pIArchive)
{
@@ -429,7 +429,7 @@ inline const char* CCryFile::GetAdjustedFilename() const
// Returns standard path otherwise.
if (gameUrl != &szAdjustedFile[0])
{
azstrcpy(szAdjustedFile, gameUrl);
azstrcpy(szAdjustedFile, AZ::IO::IArchive::MaxPath, gameUrl);
}
return szAdjustedFile;
}
+1 -1
View File
@@ -418,7 +418,7 @@ inline size_t CListenerSet<T>::MemSize() const
size += sizeof(typename TAllocatedNameVec::value_type);
for (typename TAllocatedNameVec::const_iterator iter(m_allocatedNames.begin()); iter != m_allocatedNames.end(); ++iter)
{
size += iter->GetAllocatedMemory();
size += iter->capacity() * sizeof(char) + sizeof(AZStd::string);
}
#endif
+4 -4
View File
@@ -397,11 +397,11 @@ inline bool CCryName::operator>(const CCryName& n) const
inline bool operator==(const AZStd::string& s, const CCryName& n)
{
return s == n;
return s == n.c_str();
}
inline bool operator!=(const AZStd::string& s, const CCryName& n)
{
return s != n;
return s != n.c_str();
}
inline bool operator==(const char* s, const CCryName& n)
@@ -545,11 +545,11 @@ inline bool CCryNameCRC::operator>(const CCryNameCRC& n) const
inline bool operator==(const AZStd::string& s, const CCryNameCRC& n)
{
return s == n;
return n == s.c_str();
}
inline bool operator!=(const AZStd::string& s, const CCryNameCRC& n)
{
return s != n;
return n != s.c_str();
}
inline bool operator==(const char* s, const CCryNameCRC& n)
+1 -1
View File
@@ -419,7 +419,7 @@ namespace PathUtil
//! Makes a fully specified file path from path and file name.
inline stack_string Make(const stack_string& dir, const stack_string& filename, const stack_string& ext)
{
AZStd::string path = filename;
AZStd::string path = filename.c_str();
AZ::StringFunc::Path::ReplaceExtension(path, ext.c_str());
path = AddSlash(dir.c_str()) + path;
return stack_string(path.c_str());
+2 -2
View File
@@ -387,7 +387,7 @@ public:
bool ValueChar(const char* name, char* buffer, int len)
{
string temp;
AZStd::string temp;
if (IsReading())
{
Value(name, temp);
@@ -400,7 +400,7 @@ public:
}
else
{
temp = string(buffer, buffer + len);
temp = AZStd::string(buffer, buffer + len);
Value(name, temp);
}
return true;
+3 -1
View File
@@ -14,6 +14,8 @@
#include <CryAssert.h>
#include <dirent.h>
#include <vector>
#include <AzCore/std/string/string.h>
/* Memory block identification */
#define _FREE_BLOCK 0
#define _NORMAL_BLOCK 1
@@ -344,7 +346,7 @@ private:
char m_DirectoryName[260]; //!< directory name, needed when getting file attributes on the fly
char m_ToMatch[260]; //!< pattern to match with
DIR* m_Dir; //!< directory handle
std::vector<string> m_Entries; //!< all file entries in the current directories
std::vector<AZStd::string> m_Entries; //!< all file entries in the current directories
public:
inline __finddata64_t()
+29 -28
View File
@@ -38,6 +38,7 @@
#include <sys/types.h>
#include <fcntl.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/std/string/conversions.h>
#ifdef APPLE
#include <mach/mach.h>
@@ -77,8 +78,6 @@ unsigned int g_EnableMultipleAssert = 0;//set to something else than 0 if to ena
#include <AzFramework/Utils/SystemUtilsApple.h>
#endif
#include "StringUtils.h"
#if AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE
typedef int FS_ERRNO_TYPE;
#if AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE
@@ -349,23 +348,23 @@ void _makepath(char* path, const char* drive, const char* dir, const char* filen
}
if (dir && dir[0])
{
azstrcat(tmp, dir);
azstrcat(tmp, MAX_PATH, dir);
ch = tmp[strlen(tmp) - 1];
if (ch != '/' && ch != '\\')
{
azstrcat(tmp, "\\");
azstrcat(tmp, MAX_PATH, "\\");
}
}
if (filename && filename[0])
{
azstrcat(tmp, filename);
azstrcat(tmp, MAX_PATH, filename);
if (ext && ext[0])
{
if (ext[0] != '.')
{
azstrcat(tmp, ".");
azstrcat(tmp, MAX_PATH, ".");
}
azstrcat(tmp, ext);
azstrcat(tmp, MAX_PATH, ext);
}
}
azstrcpy(path, strlen(tmp) + 1, tmp);
@@ -489,9 +488,9 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
typedef AZStd::fixed_string<AZ_MAX_PATH_LEN> path_stack_string;
const path_stack_string inPath(inpath);
string::size_type s = inPath.rfind('/', inPath.size());//position of last /
AZStd::string::size_type s = inPath.rfind('/', inPath.size());//position of last /
path_stack_string fName;
if (s == string::npos)
if (s == AZStd::string::npos)
{
if (dir)
{
@@ -503,9 +502,9 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
{
if (dir)
{
azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((string::size_type)0, (string::size_type)(s + 1))).c_str()); //assign directory
azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((AZStd::string::size_type)0, (AZStd::string::size_type)(s + 1))).c_str()); //assign directory
}
fName = inPath.substr((string::size_type)(s + 1)); //assign remaining string as rest
fName = inPath.substr((AZStd::string::size_type)(s + 1)); //assign remaining string as rest
}
if (fName.size() == 0)
{
@@ -521,8 +520,8 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
else
{
//dir and drive are now set
s = fName.find(".", (string::size_type)0);//position of first .
if (s == string::npos)
s = fName.find(".", (AZStd::string::size_type)0);//position of first .
if (s == AZStd::string::npos)
{
if (ext)
{
@@ -547,7 +546,7 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
}
else
{
azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((string::size_type)0, s)).c_str()); //assign filename
azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((AZStd::string::size_type)0, s)).c_str()); //assign filename
}
}
}
@@ -779,17 +778,17 @@ BOOL SystemTimeToFileTime(const SYSTEMTIME* syst, LPFILETIME ft)
return TRUE;
}
void adaptFilenameToLinux(string& rAdjustedFilename)
void adaptFilenameToLinux(AZStd::string& rAdjustedFilename)
{
//first replace all \\ by /
string::size_type loc = 0;
while ((loc = rAdjustedFilename.find("\\", loc)) != string::npos)
AZStd::string::size_type loc = 0;
while ((loc = rAdjustedFilename.find("\\", loc)) != AZStd::string::npos)
{
rAdjustedFilename.replace(loc, 1, "/");
}
loc = 0;
//remove /./
while ((loc = rAdjustedFilename.find("/./", loc)) != string::npos)
while ((loc = rAdjustedFilename.find("/./", loc)) != AZStd::string::npos)
{
rAdjustedFilename.replace(loc, 3, "/");
}
@@ -798,16 +797,16 @@ void adaptFilenameToLinux(string& rAdjustedFilename)
void replaceDoublePathFilename(char* szFileName)
{
//replace "\.\" by "\"
string s(szFileName);
string::size_type loc = 0;
AZStd::string s(szFileName);
AZStd::string::size_type loc = 0;
//remove /./
while ((loc = s.find("/./", loc)) != string::npos)
while ((loc = s.find("/./", loc)) != AZStd::string::npos)
{
s.replace(loc, 3, "/");
}
loc = 0;
//remove "\.\"
while ((loc = s.find("\\.\\", loc)) != string::npos)
while ((loc = s.find("\\.\\", loc)) != AZStd::string::npos)
{
s.replace(loc, 3, "\\");
}
@@ -817,8 +816,8 @@ void replaceDoublePathFilename(char* szFileName)
const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned int len)
{
//create two strings and replace the \\ by / and /./ by /
string first(cpFirst);
string second(cpSecond);
AZStd::string first(cpFirst);
AZStd::string second(cpSecond);
adaptFilenameToLinux(first);
adaptFilenameToLinux(second);
if (strlen(cpFirst) < len || strlen(cpSecond) < len)
@@ -1618,14 +1617,16 @@ const bool GetFilenameNoCase
return true;
}
DWORD GetFileAttributes(LPCSTR lpFileName)
DWORD GetFileAttributes(LPCWSTR lpFileNameW)
{
AZStd::string lpFileName;
AZStd::to_string(lpFileName, lpFileNameW);
struct stat fileStats;
const int success = stat(lpFileName, &fileStats);
const int success = stat(lpFileName.c_str(), &fileStats);
if (success == -1)
{
char adjustedFilename[MAX_PATH];
GetFilenameNoCase(lpFileName, adjustedFilename);
GetFilenameNoCase(lpFileName.c_str(), adjustedFilename);
if (stat(adjustedFilename, &fileStats) == -1)
{
return (DWORD)INVALID_FILE_ATTRIBUTES;
@@ -1648,7 +1649,7 @@ DWORD GetFileAttributes(LPCSTR lpFileName)
uint32 CryGetFileAttributes(const char* lpFileName)
{
string fn = lpFileName;
AZStd::string fn = lpFileName;
adaptFilenameToLinux(fn);
const char* buffer = fn.c_str();
return GetFileAttributes(buffer);
+11 -11
View File
@@ -435,18 +435,18 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
{
const char* const szMessage = m_bIsFatalError ? s_szFatalErrorCode : m_szBugMessage;
excName = szMessage;
azstrcpy(excCode, szMessage);
azstrcpy(excAddr, "");
azstrcpy(desc, "");
azstrcpy(m_excModule, "");
azstrcpy(excDesc, szMessage);
azstrcpy(excCode, AZ_ARRAY_SIZE(excCode), szMessage);
azstrcpy(excAddr, AZ_ARRAY_SIZE(excAddr), "");
azstrcpy(desc, AZ_ARRAY_SIZE(desc), "");
azstrcpy(m_excModule, AZ_ARRAY_SIZE(m_excModule), "");
azstrcpy(excDesc, AZ_ARRAY_SIZE(excDesc), szMessage);
}
else
{
sprintf_s(excAddr, "0x%04X:0x%p", pex->ContextRecord->SegCs, pex->ExceptionRecord->ExceptionAddress);
sprintf_s(excCode, "0x%08X", pex->ExceptionRecord->ExceptionCode);
excName = TranslateExceptionCode(pex->ExceptionRecord->ExceptionCode);
azstrcpy(desc, "");
azstrcpy(desc, AZ_ARRAY_SIZE(desc), "");
sprintf_s(excDesc, "%s\r\n%s", excName, desc);
@@ -476,9 +476,9 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
WriteLineToLog("Exception Description: %s", desc);
azstrcpy(m_excDesc, excDesc);
azstrcpy(m_excAddr, excAddr);
azstrcpy(m_excCode, excCode);
azstrcpy(m_excDesc, AZ_ARRAY_SIZE(m_excDesc), excDesc);
azstrcpy(m_excAddr, AZ_ARRAY_SIZE(m_excAddr), excAddr);
azstrcpy(m_excCode, AZ_ARRAY_SIZE(m_excCode), excCode);
char errs[32768];
@@ -504,7 +504,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
dumpCallStack(funcs);
// Fill call stack.
char str[s_iCallStackSize];
azstrcpy(str, "");
azstrcpy(str, AZ_ARRAY_SIZE(str), "");
for (unsigned int i = 0; i < funcs.size(); i++)
{
char temp[s_iCallStackSize];
@@ -514,7 +514,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex)
azstrcat(errs, temp);
azstrcat(errs, "\n");
}
azstrcpy(m_excCallstack, str);
azstrcpy(m_excCallstack, AZ_ARRAY_SIZE(m_excCallstack), str);
}
azstrcat(errorString, errs);
+1 -1
View File
@@ -237,7 +237,7 @@ void IDebugCallStack::WriteLineToLog(const char* format, ...)
char szBuffer[MAX_WARNING_LENGTH];
va_start(ArgList, format);
vsnprintf_s(szBuffer, sizeof(szBuffer), sizeof(szBuffer) - 1, format, ArgList);
azstrcat(szBuffer, "\n");
azstrcat(szBuffer, MAX_WARNING_LENGTH, "\n");
szBuffer[sizeof(szBuffer) - 1] = '\0';
va_end(ArgList);
+1 -5
View File
@@ -41,11 +41,7 @@ public:
filename = "[unknown]";
line = 0;
baseAddr = addr;
#if defined(PLATFORM_64BIT)
procName = AZStd::string::format("[%016llX]", addr);
#else
procName = AZStd::string::format("[%08X]", addr);
#endif
procName = AZStd::string::format("[%p]", addr);
}
// returns current filename
@@ -567,7 +567,7 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName)
INDENT_LOG_DURING_SCOPE();
char levelName[256];
azstrcpy(levelName, _levelName);
azstrcpy(levelName, AZ_ARRAY_SIZE(levelName), _levelName);
// Not remove a scope!!!
{
@@ -2762,7 +2762,7 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
const size_t bufSize = sizeof(buf) / sizeof(buf[0]);
wcsftime(buf, bufSize, bShowSeconds ? L"%#X" : L"%X", &theTime);
buf[bufSize - 1] = 0;
Unicode::Convert(outTimeString, buf);
AZStd::to_string(outTimeString, buf);
}
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString)
@@ -2790,7 +2790,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
const wchar_t* format = bShort ? (bIncludeWeekday ? L"%a %x" : L"%x") : L"%#x"; // long format always contains Weekday name
wcsftime(buf, bufSize, format, &theTime);
buf[bufSize - 1] = 0;
Unicode::Convert(outDateString, buf);
AZStd::to_string(outDateString, buf);
}
+4 -4
View File
@@ -508,7 +508,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
stack_string s = szBuffer;
s += "\t<Scope> ";
s += sAssetScope;
azstrcpy(szBuffer, s.c_str());
azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), s.c_str());
}
}
@@ -531,7 +531,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo
}
}
i = m_iLastHistoryItem = m_iLastHistoryItem + 1 & sz - 1;
azstrcpy(m_history[i].str, m_history[i].ptr = szSpamCheck);
azstrcpy(m_history[i].str, AZ_ARRAY_SIZE(m_history[i].str), m_history[i].ptr = szSpamCheck);
m_history[i].type = type;
m_history[i].time = time;
}
@@ -862,7 +862,7 @@ bool CLog::LogToMainThread(const char* szString, ELogType logType, bool bAdd, SL
{
// When logging from other thread then main, push all log strings to queue.
SLogMsg msg;
azstrcpy(msg.msg, szString);
azstrcpy(msg.msg, AZ_ARRAY_SIZE(msg.msg), szString);
msg.bAdd = bAdd;
msg.destination = destination;
msg.logType = logType;
@@ -1277,7 +1277,7 @@ void CLog::CreateBackupFile() const
AZStd::string bakdest = PathUtil::Make(LOG_BACKUP_PATH, sFileWithoutExt + sBackupNameAttachment + "." + sExt);
fileSystem->CreatePath(LOG_BACKUP_PATH);
azstrcpy(m_sBackupFilename, bakdest.c_str());
azstrcpy(m_sBackupFilename, AZ_ARRAY_SIZE(m_sBackupFilename), bakdest.c_str());
// Remove any existing backup file with the same name first since the copy will fail otherwise.
fileSystem->Remove(m_sBackupFilename);
fileSystem->Copy(m_szFilename, bakdest.c_str());
+1 -1
View File
@@ -282,7 +282,7 @@ static const char* GetLastSystemErrorMessage()
0,
NULL))
{
azstrcpy(szBuffer, (char*)lpMsgBuf);
azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), (char*)lpMsgBuf);
LocalFree(lpMsgBuf);
}
else
+8 -8
View File
@@ -1547,31 +1547,31 @@ const char* CXConsole::GetFlagsString(const uint32 dwFlags)
// hiding this makes it a bit more difficult for cheaters
// if(dwFlags&VF_CHEAT) azstrcat( sFlags,"CHEAT, ");
azstrcpy(sFlags, "");
azstrcpy(sFlags, AZ_ARRAY_SIZE(sFlags), "");
if (dwFlags & VF_READONLY)
{
azstrcat(sFlags, "READONLY, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "READONLY, ");
}
if (dwFlags & VF_DEPRECATED)
{
azstrcat(sFlags, "DEPRECATED, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DEPRECATED, ");
}
if (dwFlags & VF_DUMPTODISK)
{
azstrcat(sFlags, "DUMPTODISK, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DUMPTODISK, ");
}
if (dwFlags & VF_REQUIRE_LEVEL_RELOAD)
{
azstrcat(sFlags, "REQUIRE_LEVEL_RELOAD, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_LEVEL_RELOAD, ");
}
if (dwFlags & VF_REQUIRE_APP_RESTART)
{
azstrcat(sFlags, "REQUIRE_APP_RESTART, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_APP_RESTART, ");
}
if (dwFlags & VF_RESTRICTEDMODE)
{
azstrcat(sFlags, "RESTRICTEDMODE, ");
azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "RESTRICTEDMODE, ");
}
if (sFlags[0] != 0)
@@ -3325,7 +3325,7 @@ const char* CXConsole::AutoComplete(const char* substr)
const char* szCmd = cmds[i];
size_t cmdlen = strlen(szCmd);
if (cmdlen >= substrLen && azmemicmp(szCmd, substr, substrLen) == 0)
if (cmdlen >= substrLen && azstrnicmp(szCmd, substr, substrLen) == 0)
{
if (substrLen == cmdlen)
{
@@ -32,7 +32,7 @@ const char* XMLBinary::XMLBinaryReader::GetErrorDescription() const
void XMLBinary::XMLBinaryReader::SetErrorDescription(const char* text)
{
azstrcpy(m_errorDescription, text);
azstrcpy(m_errorDescription, AZ_ARRAY_SIZE(m_errorDescription), text);
}
@@ -99,7 +99,7 @@ bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node,
static const uint nMaxNodeCount = (NodeIndex) ~0;
if (m_nodes.size() > nMaxNodeCount)
{
error = AZStd::string::format("XMLBinary: Too many nodes: %d (max is %i)", m_nodes.size(), nMaxNodeCount);
error = AZStd::string::format("XMLBinary: Too many nodes: %zu (max is %i)", m_nodes.size(), nMaxNodeCount);
return false;
}