Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -65,7 +65,7 @@ void logmessage(const char* text, ...)
|
||||
error += ret;
|
||||
bufferlen -= ret;
|
||||
|
||||
int count = vsnprintf(error, bufferlen, text, arg);
|
||||
vsnprintf(error, bufferlen, text, arg);
|
||||
|
||||
AZ_TracePrintf(0, szBuffer);
|
||||
|
||||
|
||||
@@ -169,7 +169,6 @@ bool CSTLHelper::FromFile(const std::string& rFileName, std::vector<uint8_t>&
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t nNumRead = 0;
|
||||
rIn.resize(fileSize);
|
||||
AZ::IO::SystemFile::SizeType actualReadAmount = inputFile.Read(fileSize, &rIn[0]);
|
||||
|
||||
@@ -276,7 +275,7 @@ bool CSTLHelper::AppendToFile(const std::string& rFileName, const std::vector<ui
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::IO::SystemFile::SizeType bytesWritten = outputFile.Write(rOut.data(), rOut.size());
|
||||
[[maybe_unused]] AZ::IO::SystemFile::SizeType bytesWritten = outputFile.Write(rOut.data(), rOut.size());
|
||||
AZ_Warning("ShaderCompiler", bytesWritten == rOut.size(), "Did not write out all the data to the file: %s", rFileName.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -56,14 +56,15 @@ void CCrySimpleCache::Init()
|
||||
|
||||
std::string CCrySimpleCache::CreateFileName(const tdHash& rHash) const
|
||||
{
|
||||
std::string Name;
|
||||
Name = CSTLHelper::Hash2String(rHash);
|
||||
AZStd::string Name;
|
||||
Name = CSTLHelper::Hash2String(rHash).c_str();
|
||||
char Tmp[4] = "012";
|
||||
Tmp[0] = Name.c_str()[0];
|
||||
Tmp[1] = Name.c_str()[1];
|
||||
Tmp[2] = Name.c_str()[2];
|
||||
|
||||
return SEnviropment::Instance().m_CachePath + Tmp + "/" + Name;
|
||||
AZ::IO::Path resultFileName = SEnviropment::Instance().m_CachePath / Tmp / Name;
|
||||
return std::string{ resultFileName.c_str(), resultFileName.Native().size() };
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +160,6 @@ bool CCrySimpleCache::LoadCacheFile(const std::string& filename)
|
||||
uint32_t num = 0;
|
||||
|
||||
uint64_t nFilePos = 0;
|
||||
uint64_t nFilePos2 = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZ::IO::SystemFile cacheFile;
|
||||
@@ -303,7 +303,8 @@ void CCrySimpleCache::ThreadFunc_SavePendingCacheEntries()
|
||||
|
||||
if (pPendingCacheEntry)
|
||||
{
|
||||
CSTLHelper::AppendToFile(SEnviropment::Instance().m_CachePath + "Cache.dat", *pPendingCacheEntry);
|
||||
AZ::IO::Path cacheDatPath = SEnviropment::Instance().m_CachePath / "Cache.dat";
|
||||
CSTLHelper::AppendToFile(std::string{ cacheDatPath.c_str(), cacheDatPath.Native().size() }, *pPendingCacheEntry);
|
||||
delete pPendingCacheEntry;
|
||||
}
|
||||
} while (!bListEmpty);
|
||||
|
||||
@@ -180,7 +180,7 @@ void CCrySimpleErrorLog::SendMail()
|
||||
char DispFilename[1024];
|
||||
azsprintf(DispFilename, "%d-%s", a + 1, err->GetFilename().c_str());
|
||||
|
||||
std::string sErrorFile = SEnviropment::Instance().m_ErrorPath + Filename;
|
||||
std::string sErrorFile = (SEnviropment::Instance().m_ErrorPath / Filename).c_str();
|
||||
|
||||
std::vector<uint8_t> bytes;
|
||||
std::string text = err->GetFileContents();
|
||||
@@ -211,7 +211,7 @@ void CCrySimpleErrorLog::SendMail()
|
||||
CSMTPMailer::tstrcol bcc;
|
||||
|
||||
CSMTPMailer mail("", "", SEnviropment::Instance().m_MailServer);
|
||||
bool res = mail.Send(SEnviropment::Instance().m_FailEMail, Rcpt, cc, bcc, err->GetErrorName(), body, Attachment);
|
||||
mail.Send(SEnviropment::Instance().m_FailEMail, Rcpt, cc, bcc, err->GetErrorName(), body, Attachment);
|
||||
|
||||
a = 0;
|
||||
body = mailBody;
|
||||
|
||||
@@ -133,12 +133,12 @@ protected:
|
||||
|
||||
|
||||
Ret += CreateInfoText("<b>Setup</b>:", "");
|
||||
Ret += CreateInfoText("Root", SEnviropment::Instance().m_Root);
|
||||
Ret += CreateInfoText("CompilerPath", SEnviropment::Instance().m_CompilerPath);
|
||||
Ret += CreateInfoText("CachePath", SEnviropment::Instance().m_CachePath);
|
||||
Ret += CreateInfoText("TempPath", SEnviropment::Instance().m_TempPath);
|
||||
Ret += CreateInfoText("ErrorPath", SEnviropment::Instance().m_ErrorPath);
|
||||
Ret += CreateInfoText("ShaderPath", SEnviropment::Instance().m_ShaderPath);
|
||||
Ret += CreateInfoText("Root", SEnviropment::Instance().m_Root.c_str());
|
||||
Ret += CreateInfoText("CompilerPath", SEnviropment::Instance().m_CompilerPath.c_str());
|
||||
Ret += CreateInfoText("CachePath", SEnviropment::Instance().m_CachePath.c_str());
|
||||
Ret += CreateInfoText("TempPath", SEnviropment::Instance().m_TempPath.c_str());
|
||||
Ret += CreateInfoText("ErrorPath", SEnviropment::Instance().m_ErrorPath.c_str());
|
||||
Ret += CreateInfoText("ShaderPath", SEnviropment::Instance().m_ShaderPath.c_str());
|
||||
Ret += CreateInfoText("FailEMail", SEnviropment::Instance().m_FailEMail);
|
||||
Ret += CreateInfoText("MailServer", SEnviropment::Instance().m_MailServer);
|
||||
Ret += CreateInfoText("port", SEnviropment::Instance().m_port);
|
||||
|
||||
+20
-21
@@ -282,7 +282,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
shaderPath = AZStd::string::format("%s%s/", SEnviropment::Instance().m_ShaderPath.c_str(), language.c_str());
|
||||
}
|
||||
|
||||
NormalizePath(shaderPath);
|
||||
shaderPath = AZ::IO::PathView(shaderPath).LexicallyNormal().Native();
|
||||
if (!IsPathValid(shaderPath))
|
||||
{
|
||||
State(ECSJS_ERROR);
|
||||
@@ -347,17 +347,14 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
static AZStd::atomic_long nTmpCounter = { 0 };
|
||||
++nTmpCounter;
|
||||
|
||||
char tmpstr[64];
|
||||
azsprintf(tmpstr, "%ld", static_cast<long>(nTmpCounter));
|
||||
const auto tmpIndex = AZStd::string::format("%ld", static_cast<long>(nTmpCounter));
|
||||
const AZ::IO::Path TmpIn = SEnviropment::Instance().m_TempPath / (tmpIndex + ".In");
|
||||
const AZ::IO::Path TmpOut = SEnviropment::Instance().m_TempPath / (tmpIndex + ".Out");
|
||||
CCrySimpleFileGuard FGTmpIn(TmpIn.c_str());
|
||||
CCrySimpleFileGuard FGTmpOut(TmpOut.c_str());
|
||||
CSTLHelper::ToFile(TmpIn.c_str(), std::vector<uint8_t>(pProgram, &pProgram[strlen(pProgram)]));
|
||||
|
||||
|
||||
const std::string TmpIn = SEnviropment::Instance().m_TempPath + tmpstr + ".In";
|
||||
const std::string TmpOut = SEnviropment::Instance().m_TempPath + tmpstr + ".Out";
|
||||
CCrySimpleFileGuard FGTmpIn(TmpIn);
|
||||
CCrySimpleFileGuard FGTmpOut(TmpOut);
|
||||
CSTLHelper::ToFile(TmpIn, std::vector<uint8_t>(pProgram, &pProgram[strlen(pProgram)]));
|
||||
|
||||
const AZStd::string compilerPath = SEnviropment::Instance().m_CompilerPath.c_str();
|
||||
AZ::IO::Path compilerPath = SEnviropment::Instance().m_CompilerPath;
|
||||
AZStd::string command;
|
||||
if (m_Version >= EPV_V0022)
|
||||
{
|
||||
@@ -370,7 +367,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string commandStringToFormat = compilerPath + compilerExecutable;
|
||||
AZStd::string commandStringToFormat = (compilerPath / compilerExecutable).Native();
|
||||
|
||||
#if defined(AZ_PLATFORM_LINUX) || defined(AZ_PLATFORM_MAC)
|
||||
// Surrounding compiler path+executable with quotes to support spaces in the path.
|
||||
@@ -392,7 +389,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string fxcLocation = compilerPath + fxcCompilerExecutable;
|
||||
AZ::IO::Path fxcLocation = compilerPath / fxcCompilerExecutable;
|
||||
|
||||
// Handle an extra string parameter to specify the base directory where the fxc compiler is located
|
||||
command = AZStd::move(AZStd::string::format(commandStringToFormat.c_str(), fxcLocation.c_str(), pEntry, pProfile, TmpOut.c_str(), TmpIn.c_str()));
|
||||
@@ -434,7 +431,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
AZStd::string insertPattern = "\\\"";
|
||||
|
||||
// Search for the next space until that path exists. Then we assume that's the path to the executable.
|
||||
size_t startPos = command.find(compilerPath);
|
||||
size_t startPos = command.find(compilerPath.Native());
|
||||
for (size_t pos = command.find(" ", startPos); pos != AZStd::string::npos; pos = command.find(" ", pos + 1))
|
||||
{
|
||||
if (AZ::IO::SystemFile::Exists(command.substr(startPos, pos - startPos).c_str()))
|
||||
@@ -449,7 +446,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
command = AZStd::move(AZStd::string::format(pCompileFlags, pEntry, pProfile, TmpOut.c_str(), TmpIn.c_str()));
|
||||
}
|
||||
|
||||
command = compilerPath + command;
|
||||
command = compilerPath.Native() + command;
|
||||
}
|
||||
|
||||
AZStd::string hardwareTarget;
|
||||
@@ -540,11 +537,13 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
std::string tags = pTags ? pTags : "";
|
||||
|
||||
std::string filteredError;
|
||||
CSTLHelper::Replace(filteredError, outError, TmpIn + ".patched", "%filename%"); // DXPS does its own patching
|
||||
CSTLHelper::Replace(filteredError, filteredError, TmpIn, "%filename%");
|
||||
AZ::IO::Path patchFilePath = TmpIn;
|
||||
patchFilePath.ReplaceFilename(AZ::IO::PathView{ AZStd::string{ TmpIn.Filename().Native() } + ".patched" });
|
||||
CSTLHelper::Replace(filteredError, outError, patchFilePath.c_str(), "%filename%"); // DXPS does its own patching
|
||||
CSTLHelper::Replace(filteredError, filteredError, TmpIn.c_str(), "%filename%");
|
||||
// replace any that don't have the full path
|
||||
CSTLHelper::Replace(filteredError, filteredError, std::string(tmpstr) + ".In.patched", "%filename%"); // DXPS does its own patching
|
||||
CSTLHelper::Replace(filteredError, filteredError, std::string(tmpstr) + ".In", "%filename%");
|
||||
CSTLHelper::Replace(filteredError, filteredError, (tmpIndex + ".In.patched").c_str(), "%filename%"); // DXPS does its own patching
|
||||
CSTLHelper::Replace(filteredError, filteredError, (tmpIndex + ".In").c_str(), "%filename%");
|
||||
|
||||
CSTLHelper::Replace(filteredError, filteredError, "\r\n", "\n");
|
||||
|
||||
@@ -552,11 +551,11 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
|
||||
throw new CCompilerError(pEntry, filteredError, ccs, sIP, pShaderRequestLine, pProgram, project, platform.c_str(), compiler.c_str(), language.c_str(), tags, pProfile);
|
||||
}
|
||||
|
||||
if (!CSTLHelper::FromFile(TmpOut, rVec))
|
||||
if (!CSTLHelper::FromFile(TmpOut.c_str(), rVec))
|
||||
{
|
||||
State(ECSJS_ERROR_FILEIO);
|
||||
std::string errorString("Could not read: ");
|
||||
errorString += TmpOut;
|
||||
errorString += std::string(TmpOut.c_str(), TmpOut.Native().size());
|
||||
CrySimple_ERROR(errorString.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
+6
-2
@@ -19,6 +19,7 @@
|
||||
#include <Core/Common.h>
|
||||
#include <tinyxml/tinyxml.h>
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
|
||||
@@ -30,7 +31,7 @@ CCrySimpleJobGetShaderList::CCrySimpleJobGetShaderList(uint32_t requestIP, std::
|
||||
|
||||
bool CCrySimpleJobGetShaderList::Execute(const TiXmlElement* pElement)
|
||||
{
|
||||
AZStd::string shaderListFilename;
|
||||
AZ::IO::Path shaderListFilename;
|
||||
|
||||
const char* project = pElement->Attribute("Project");
|
||||
const char* shaderList = pElement->Attribute("ShaderList");
|
||||
@@ -38,7 +39,10 @@ bool CCrySimpleJobGetShaderList::Execute(const TiXmlElement* pElement)
|
||||
const char* compiler = pElement->Attribute("Compiler");
|
||||
const char* language = pElement->Attribute("Language");
|
||||
|
||||
shaderListFilename = AZStd::string::format("./Cache/%s%s-%s-%s/%s", project, platform, compiler, language, shaderList);
|
||||
shaderListFilename = project;
|
||||
shaderListFilename /= "Cache";
|
||||
shaderListFilename /= AZStd::string::format("%s-%s-%s", platform, compiler, language);
|
||||
shaderListFilename /= shaderList;
|
||||
|
||||
//open the file and read into the rVec
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <Core/WindowsAPIImplementation.h>
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
|
||||
CCrySimpleJobRequest::CCrySimpleJobRequest(EProtocolVersion Version, uint32_t requestIP)
|
||||
@@ -41,7 +42,7 @@ bool CCrySimpleJobRequest::Execute(const TiXmlElement* pElement)
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string shaderListFilename;
|
||||
AZ::IO::Path shaderListFilename;
|
||||
if (m_Version >= EPV_V0023)
|
||||
{
|
||||
const char* project = pElement->Attribute("Project");
|
||||
@@ -64,20 +65,16 @@ bool CCrySimpleJobRequest::Execute(const TiXmlElement* pElement)
|
||||
AZStd::string compiler = pElement->Attribute("Compiler");
|
||||
AZStd::string language = pElement->Attribute("Language");
|
||||
|
||||
shaderListFilename = AZStd::string::format("%s%s-%s-%s/%s", project, platform.c_str(), compiler.c_str(), language.c_str(), shaderList);
|
||||
shaderListFilename = project;
|
||||
shaderListFilename /= "Cache";
|
||||
shaderListFilename /= AZStd::string::format("%s-%s-%s", platform.c_str(), compiler.c_str(), language.c_str());
|
||||
shaderListFilename /= shaderList;
|
||||
}
|
||||
else
|
||||
{
|
||||
// In previous versions Platform attribute is the shader list filename directly
|
||||
shaderListFilename = pElement->Attribute("Platform");
|
||||
}
|
||||
|
||||
if (shaderListFilename.length() >= AZ_MAX_PATH_LEN)
|
||||
{
|
||||
State(ECSJS_ERROR);
|
||||
CrySimple_ERROR("Shader list filename is too long");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string shaderRequestLine(shaderRequest);
|
||||
tdEntryVec toks;
|
||||
|
||||
@@ -71,15 +71,6 @@
|
||||
|
||||
AZStd::atomic_long CCrySimpleServer::ms_ExceptionCount = {0};
|
||||
|
||||
const static std::string SHADER_PROFILER = "NVShaderPerf" EXTENSION;
|
||||
|
||||
const static std::string SHADER_PATH_SOURCE = "Source";
|
||||
const static std::string SHADER_PATH_BINARY = "Binary";
|
||||
const static std::string SHADER_PATH_HALFSTRIPPED = "HalfStripped";
|
||||
const static std::string SHADER_PATH_DISASSEMBLED = "DisAsm";
|
||||
const static std::string SHADER_PATH_STRIPPPED = "Stripped";
|
||||
const static std::string SHADER_PATH_CACHE = "Cache";
|
||||
|
||||
static const bool autoDeleteJobWhenDone = true;
|
||||
static const int sleepTimeWhenWaiting = 10;
|
||||
|
||||
@@ -335,7 +326,6 @@ void CompileJob::Process()
|
||||
}
|
||||
|
||||
const char* pVersion = pElement->Attribute("Version");
|
||||
const char* pPlatform = pElement->Attribute("Platform");
|
||||
const char* pHardwareTarget = nullptr;
|
||||
|
||||
//new request type?
|
||||
@@ -575,31 +565,45 @@ void TickThread()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void LoadCache()
|
||||
{
|
||||
const std::string& cachePath = SEnviropment::Instance().m_CachePath;
|
||||
if (CCrySimpleCache::Instance().LoadCacheFile(cachePath + "Cache.dat"))
|
||||
AZ::IO::Path cacheDatFile{ SEnviropment::Instance().m_CachePath };
|
||||
AZ::IO::Path cacheBakFile = cacheDatFile;
|
||||
cacheDatFile /= "Cache.dat";
|
||||
cacheBakFile /= "Cache.bak";
|
||||
if (CCrySimpleCache::Instance().LoadCacheFile(cacheDatFile.c_str()))
|
||||
{
|
||||
AZ::IO::Path cacheBakFile2 = cacheBakFile;
|
||||
cacheBakFile2.ReplaceFilename("Cache.bak2");
|
||||
|
||||
printf("Creating cache backup...\n");
|
||||
AZ::IO::SystemFile::Delete((cachePath + "Cache.bak2").c_str());
|
||||
printf("Move %s to %s\n", (cachePath + "Cache.bak").c_str(), (cachePath + "Cache.bak2").c_str());
|
||||
AZ::IO::SystemFile::Rename((cachePath + "Cache.bak").c_str(), (cachePath + "Cache.bak2").c_str());
|
||||
printf("Copy %s to %s\n", (cachePath + "Cache.dat").c_str(), (cachePath + "Cache.bak").c_str());
|
||||
CopyFileOnPlatform((cachePath + "Cache.dat").c_str(), (cachePath + "Cache.bak").c_str(), FALSE);
|
||||
AZ::IO::SystemFile::Delete(cacheBakFile2.c_str());
|
||||
printf("Move %s to %s\n", cacheBakFile.c_str(), cacheBakFile2.c_str());
|
||||
AZ::IO::SystemFile::Rename(cacheBakFile.c_str(), cacheBakFile2.c_str());
|
||||
printf("Copy %s to %s\n", cacheDatFile.c_str(), cacheBakFile.c_str());
|
||||
CopyFileOnPlatform(cacheDatFile.c_str(), cacheBakFile.c_str(), false);
|
||||
printf("Cache backup done.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restoring backup cache!
|
||||
printf("Cache file corrupted!!!\n");
|
||||
if (AZ::IO::SystemFile::Exists(cacheDatFile.c_str()))
|
||||
{
|
||||
printf("Cache file corrupted!!!\n");
|
||||
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
|
||||
}
|
||||
|
||||
printf("Restoring backup cache...\n");
|
||||
AZ::IO::SystemFile::Delete((cachePath + "Cache.dat").c_str());
|
||||
printf("Copy %s to %s\n", (cachePath + "Cache.bak").c_str(), (cachePath + "Cache.dat").c_str());
|
||||
CopyFileOnPlatform((cachePath + "Cache.bak").c_str(), (cachePath + "Cache.dat").c_str(), FALSE);
|
||||
if (!CCrySimpleCache::Instance().LoadCacheFile(cachePath + "Cache.dat"))
|
||||
printf("Copy %s to %s\n", cacheBakFile.c_str(), cacheDatFile.c_str());
|
||||
CopyFileOnPlatform(cacheBakFile.c_str(), cacheDatFile.c_str(), false);
|
||||
if (!CCrySimpleCache::Instance().LoadCacheFile(cacheDatFile.c_str()))
|
||||
{
|
||||
// Backup file corrupted too!
|
||||
printf("Backup file corrupted too!!!\n");
|
||||
if (AZ::IO::SystemFile::Exists(cacheDatFile.c_str()))
|
||||
{
|
||||
printf("Backup file corrupted too!!!\n");
|
||||
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
|
||||
}
|
||||
printf("Deleting cache completely\n");
|
||||
AZ::IO::SystemFile::Delete((cachePath + "Cache.dat").c_str());
|
||||
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,56 +668,9 @@ CCrySimpleServer::CCrySimpleServer()
|
||||
CrySimple_SECURE_END
|
||||
}
|
||||
|
||||
bool GetBaseDirectory(AZStd::string& baseDir)
|
||||
{
|
||||
char executableDir[AZ_MAX_PATH_LEN];
|
||||
if (AZ::Utils::GetExecutableDirectory(executableDir, AZ_MAX_PATH_LEN) == AZ::Utils::ExecutablePathResult::Success)
|
||||
{
|
||||
AZStd::string_view executableDirView(executableDir);
|
||||
if (executableDirView.size() > 1 && !executableDirView.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR) && executableDirView.size() < AZStd::size(executableDir) - 1)
|
||||
{
|
||||
executableDir[executableDirView.size()] = AZ_CORRECT_FILESYSTEM_SEPARATOR;
|
||||
executableDir[executableDirView.size() + 1] = '\0';
|
||||
executableDirView = { executableDir, executableDirView.size() + 1 };
|
||||
}
|
||||
baseDir = AZStd::string(executableDir);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void NormalizePath(AZStd::string& pathToNormalize)
|
||||
{
|
||||
AzFramework::StringFunc::Root::Normalize(pathToNormalize);
|
||||
}
|
||||
|
||||
void NormalizePath(std::string& pathToNormalize)
|
||||
{
|
||||
AZStd::string tempString = pathToNormalize.c_str();
|
||||
NormalizePath(tempString);
|
||||
pathToNormalize = tempString.c_str();
|
||||
}
|
||||
|
||||
bool IsPathValid(const AZStd::string& path)
|
||||
{
|
||||
// Calculating base directory every time.
|
||||
// It's slower than using a cached value, but safer.
|
||||
AZStd::string baseDir;
|
||||
if (GetBaseDirectory(baseDir))
|
||||
{
|
||||
AZStd::string basePath(AZ::IO::Path(baseDir).LexicallyNormal().Native());
|
||||
AZStd::string subPath(AZ::IO::Path(path).LexicallyNormal().Native());
|
||||
return strncmp(basePath.c_str(), subPath.c_str(), basePath.size()) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return AZ::IO::PathView(path).IsRelativeTo(AZ::IO::PathView(SEnviropment::Instance().m_Root));
|
||||
}
|
||||
|
||||
bool IsPathValid(const std::string& path)
|
||||
@@ -724,48 +681,29 @@ bool IsPathValid(const std::string& path)
|
||||
|
||||
void CCrySimpleServer::Init()
|
||||
{
|
||||
char executableDir[AZ_MAX_PATH_LEN];
|
||||
AZ::Utils::GetExecutableDirectory(executableDir, AZ_MAX_PATH_LEN);
|
||||
AZStd::string_view executableDirView(executableDir);
|
||||
if (executableDirView.size() > 1 && !executableDirView.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR) && executableDirView.size() < AZStd::size(executableDir) - 1)
|
||||
{
|
||||
executableDir[executableDirView.size()] = AZ_CORRECT_FILESYSTEM_SEPARATOR;
|
||||
executableDir[executableDirView.size() + 1] = '\0';
|
||||
executableDirView = { executableDir, executableDirView.size() + 1 };
|
||||
}
|
||||
SEnviropment::Instance().m_Root = std::string(executableDir);
|
||||
|
||||
AZStd::string baseDir;
|
||||
GetBaseDirectory(baseDir);
|
||||
SEnviropment::Instance().m_CompilerPath = baseDir.c_str();
|
||||
SEnviropment::Instance().m_CompilerPath += "/Compiler/";
|
||||
|
||||
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_Root + "Cache/";
|
||||
SEnviropment::Instance().m_Root = AZ::Utils::GetExecutableDirectory();
|
||||
SEnviropment::Instance().m_CompilerPath = SEnviropment::Instance().m_Root / "Compiler";
|
||||
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_Root / "Cache";
|
||||
|
||||
if (SEnviropment::Instance().m_TempPath.empty())
|
||||
{
|
||||
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_Root + "Temp/";
|
||||
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_Root / "Temp";
|
||||
}
|
||||
if (SEnviropment::Instance().m_ErrorPath.empty())
|
||||
{
|
||||
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_Root + "Error/";
|
||||
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_Root / "Error";
|
||||
}
|
||||
if (SEnviropment::Instance().m_ShaderPath.empty())
|
||||
{
|
||||
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_Root + "Shaders/";
|
||||
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_Root / "Shaders";
|
||||
}
|
||||
|
||||
NormalizePath(SEnviropment::Instance().m_Root);
|
||||
NormalizePath(SEnviropment::Instance().m_CompilerPath);
|
||||
NormalizePath(SEnviropment::Instance().m_CachePath);
|
||||
NormalizePath(SEnviropment::Instance().m_ErrorPath);
|
||||
NormalizePath(SEnviropment::Instance().m_TempPath);
|
||||
NormalizePath(SEnviropment::Instance().m_ShaderPath);
|
||||
|
||||
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_ErrorPath.c_str());
|
||||
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_TempPath.c_str());
|
||||
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_CachePath.c_str());
|
||||
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_ShaderPath.c_str());
|
||||
SEnviropment::Instance().m_Root = SEnviropment::Instance().m_Root.LexicallyNormal();
|
||||
SEnviropment::Instance().m_CompilerPath = SEnviropment::Instance().m_CompilerPath.LexicallyNormal();
|
||||
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_CachePath.LexicallyNormal();
|
||||
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_ErrorPath.LexicallyNormal();
|
||||
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_TempPath.LexicallyNormal();
|
||||
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_ShaderPath.LexicallyNormal();
|
||||
|
||||
if (SEnviropment::Instance().m_Caching)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define __CRYSIMPLESERVER__
|
||||
|
||||
#include <Core/Common.h>
|
||||
#include <AzCore/IO//Path/Path.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/unordered_set.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
@@ -24,11 +25,6 @@
|
||||
|
||||
extern bool g_Success;
|
||||
|
||||
bool GetExecutableDirectory(AZStd::string& executableDir);
|
||||
bool GetBaseDirectory(AZStd::string& baseDir);
|
||||
|
||||
void NormalizePath(AZStd::string& pathToNormalize);
|
||||
void NormalizePath(std::string& pathToNormalize);
|
||||
|
||||
bool IsPathValid(const AZStd::string& path);
|
||||
bool IsPathValid(const std::string& path);
|
||||
@@ -42,12 +38,12 @@ class CCrySimpleSock;
|
||||
class SEnviropment
|
||||
{
|
||||
public:
|
||||
std::string m_Root;
|
||||
std::string m_CompilerPath;
|
||||
std::string m_CachePath;
|
||||
std::string m_TempPath;
|
||||
std::string m_ErrorPath;
|
||||
std::string m_ShaderPath;
|
||||
AZ::IO::Path m_Root;
|
||||
AZ::IO::Path m_CompilerPath;
|
||||
AZ::IO::Path m_CachePath;
|
||||
AZ::IO::Path m_TempPath;
|
||||
AZ::IO::Path m_ErrorPath;
|
||||
AZ::IO::Path m_ShaderPath;
|
||||
|
||||
std::string m_FailEMail;
|
||||
std::string m_MailServer;
|
||||
|
||||
@@ -554,7 +554,6 @@ bool CCrySimpleSock::Recv(std::vector<uint8_t>& rVec)
|
||||
|
||||
if (size.m_Data64 > MAX_DATA_SIZE)
|
||||
{
|
||||
int WSAError = WSAGetLastError();
|
||||
char acTmp[MAX_ERROR_MESSAGE_SIZE];
|
||||
azsprintf(acTmp, "Error while receiving size of data - Size is greater than max support data size.");
|
||||
CrySimple_ERROR(acTmp);
|
||||
|
||||
@@ -74,7 +74,7 @@ void CShaderList::Add(const std::string& rShaderListName, const char* pLine)
|
||||
CCrySimpleMutexAutoLock Lock2(m_Mutex2); //load/save mutex
|
||||
m_ShaderLists[rShaderListName] = new CShaderListFile(rShaderListName);
|
||||
it = m_ShaderLists.find(rShaderListName);
|
||||
it->second->Load((SEnviropment::Instance().m_CachePath + rShaderListName).c_str());
|
||||
it->second->Load((SEnviropment::Instance().m_CachePath / AZStd::string_view{ rShaderListName.c_str(), rShaderListName.size() }).c_str());
|
||||
}
|
||||
}
|
||||
it->second->InsertLine(pLine);
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
if (azstricmp(strKey.c_str(), "TempDir") == 0)
|
||||
{
|
||||
SEnviropment::Instance().m_TempPath = AddSlash(strValue);
|
||||
SEnviropment::Instance().m_TempPath = AZStd::string_view{ strValue.c_str(), strValue.size() };
|
||||
}
|
||||
if (azstricmp(strKey.c_str(), "MailServer") == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user