Conversion to unicode, everything except StreamerConfiguration
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -72,6 +72,7 @@ namespace AZ
|
||||
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzCore/Debug/TraceMessagesDrillerBus.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -22,7 +24,7 @@ namespace AZ
|
||||
LPTOP_LEVEL_EXCEPTION_FILTER g_previousExceptionHandler = nullptr;
|
||||
#endif
|
||||
|
||||
const int g_maxMessageLength = 4096;
|
||||
constexpr int g_maxMessageLength = 4096;
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
@@ -58,15 +60,18 @@ namespace AZ
|
||||
TerminateProcess(GetCurrentProcess(), exitCode);
|
||||
}
|
||||
|
||||
void OutputToDebugger(const char* window, const char* message)
|
||||
void OutputToDebugger([[maybe_unused]] const char* window, const char* message)
|
||||
{
|
||||
AZ_UNUSED(window);
|
||||
wchar_t messageW[g_maxMessageLength];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, messageW, message, g_maxMessageLength - 1) == 0)
|
||||
AZStd::fixed_wstring<g_maxMessageLength> tmpW;
|
||||
if(window)
|
||||
{
|
||||
OutputDebugStringW(messageW);
|
||||
AZStd::to_wstring(tmpW, window);
|
||||
tmpW += L": ";
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
tmpW.clear();
|
||||
}
|
||||
AZStd::to_wstring(tmpW, message);
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -14,8 +15,9 @@ namespace AZ
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
void OutputToDebugger(const char* title, const char* message)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AZ
|
||||
return errno;
|
||||
}
|
||||
|
||||
void SharedMemory_Mac::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace AZ
|
||||
|
||||
static int GetLastError();
|
||||
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
CreateResult Create(const char* name, unsigned int size, bool openIfCreated);
|
||||
bool Open(const char* name);
|
||||
void Close();
|
||||
|
||||
+2
-2
@@ -290,7 +290,7 @@ namespace AZ::IO
|
||||
static bool CollectHardwareInfo(HardwareInformation& hardwareInfo, bool addAllDrives, bool reportHardware)
|
||||
{
|
||||
char drives[512];
|
||||
if (::GetLogicalDriveStrings(sizeof(drives) - 1, drives))
|
||||
if (::GetLogicalDriveStringsA(sizeof(drives) - 1, drives))
|
||||
{
|
||||
AZStd::unordered_map<DWORD, DriveInformation> driveMappings;
|
||||
char* driveIt = drives;
|
||||
@@ -318,7 +318,7 @@ namespace AZ::IO
|
||||
deviceName += driveIt;
|
||||
deviceName.erase(deviceName.length() - 1); // Erase the slash.
|
||||
|
||||
HANDLE deviceHandle = ::CreateFile(
|
||||
HANDLE deviceHandle = ::CreateFileA(
|
||||
deviceName.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (deviceHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/IPC/SharedMemory.h>
|
||||
#include <AzCore/std/parallel/spin_mutex.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -21,16 +22,17 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
void SharedMemory_Windows::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(AZStd::fixed_wstring<256>& dest, const char* name, const wchar_t* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
azsnprintf(dest, length, "%s_Mutex", name);
|
||||
AZStd::to_wstring(dest, name);
|
||||
dest += L"_";
|
||||
dest += suffix;
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Windows::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
// Security attributes
|
||||
SECURITY_ATTRIBUTES secAttr;
|
||||
@@ -42,9 +44,7 @@ namespace AZ
|
||||
SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE);
|
||||
|
||||
// Obtain global mutex
|
||||
AZStd::wstring fullNameW;
|
||||
AZStd::to_wstring(fullNameW, fullName);
|
||||
m_globalMutex = CreateMutexW(&secAttr, FALSE, fullNameW.c_str());
|
||||
m_globalMutex = CreateMutexW(&secAttr, FALSE, fullName.c_str());
|
||||
DWORD error = GetLastError();
|
||||
if (m_globalMutex == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -53,8 +53,8 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullNameW.c_str());
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullName.c_str());
|
||||
error = GetLastError();
|
||||
if (m_mapHandle == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -67,12 +67,10 @@ namespace AZ
|
||||
|
||||
bool SharedMemory_Windows::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
AZStd::wstring fullNameW;
|
||||
AZStd::to_wstring(fullNameW, fullName);
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullNameW.c_str());
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullName.c_str());
|
||||
AZ_Warning("AZSystem", m_globalMutex != NULL, "Failed to open OS mutex [%s]\n", m_name);
|
||||
if (m_globalMutex == NULL)
|
||||
{
|
||||
@@ -80,8 +78,8 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullNameW.c_str());
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullName.c_str());
|
||||
if (m_mapHandle == NULL)
|
||||
{
|
||||
AZ_TracePrintf("AZSystem", "OpenFileMapping %s failed with error %d\n", m_name, GetLastError());
|
||||
|
||||
@@ -41,9 +41,6 @@ namespace AZ
|
||||
HANDLE m_mapHandle;
|
||||
HANDLE m_globalMutex;
|
||||
int m_lastLockResult;
|
||||
|
||||
private:
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
};
|
||||
|
||||
using SharedMemory_Platform = SharedMemory_Windows;
|
||||
|
||||
Reference in New Issue
Block a user