linux fixes
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -51,74 +51,72 @@
|
||||
# define azvscprintf(_format, _va_list) _vscprintf(_format, _va_list)
|
||||
# define azscwprintf _scwprintf
|
||||
# define azvscwprintf _vscwprintf
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat strcat_s
|
||||
# define azstrncat strncat_s
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy strcpy_s
|
||||
# define azstrncpy strncpy_s
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
# define azmemicmp _memicmp
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat_s(_dest, _destSize, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat_s(_dest, _destSize, _src, _count)
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy_s(_dest, _destSize, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy_s(_dest, _destSize, _src, _count)
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen fopen_s
|
||||
# define azfopen(_fp, _filename, _attrib) fopen_s(_fp, _filename, _attrib)
|
||||
# define azfscanf fscanf_s
|
||||
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
#else
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# if AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# else
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# endif
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# if defined(NDK_REV_MAJOR) && NDK_REV_MAJOR < 16
|
||||
# define azisfinite __isfinitef
|
||||
# define azisfinite __isfinitef
|
||||
# else
|
||||
# define azisfinite isfinite
|
||||
# define azisfinite isfinite
|
||||
# endif
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcsicmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
# define azmemicmp memicmp
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcscasecmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
|
||||
# define azsprintf sprintf
|
||||
# define azstrlwr(_buffer, _size) strlwr(_buffer)
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace AZStd
|
||||
template<size_t Size = sizeof(wchar_t)>
|
||||
struct WCharTPlatformConverter
|
||||
{
|
||||
static_assert(Size == size_t{ 2 } || Size == size_t{ 4 }, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
|
||||
template<class Allocator1>
|
||||
static inline void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const wchar_t* first, const wchar_t* last)
|
||||
{
|
||||
@@ -41,12 +43,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t MaxElementCount>
|
||||
@@ -60,12 +56,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void to_string(char* dest, size_t destSize, const wchar_t* first, const wchar_t* last)
|
||||
@@ -78,10 +68,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf32to8(first, last, dest, destSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(false, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator1>
|
||||
@@ -95,12 +81,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4");
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t MaxElementCount>
|
||||
@@ -114,12 +94,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void to_wstring(wchar_t* dest, size_t destSize, const char* first, const char* last)
|
||||
@@ -132,10 +106,6 @@ namespace AZStd
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(first, last, dest, destSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(false, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace AZ
|
||||
result.m_pathIncludesFilename = true;
|
||||
// Platform specific get exe path: http://stackoverflow.com/a/1024937
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea
|
||||
AZStd::wstring pathBuffer;
|
||||
pathBuffer.resize(exeStorageSize);
|
||||
const DWORD pathLen = GetModuleFileName(nullptr, pathBuffer.data(), static_cast<DWORD>(exeStorageSize));
|
||||
wchar_t pathBufferW[AZ_MAX_PATH_LEN] = { 0 };
|
||||
const DWORD pathLen = GetModuleFileNameW(nullptr, pathBufferW, static_cast<DWORD>(exeStorageSize));
|
||||
const DWORD errorCode = GetLastError();
|
||||
if (pathLen == exeStorageSize && errorCode == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
@@ -44,7 +43,7 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBuffer.c_str());
|
||||
AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBufferW);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
+4
-2
@@ -20,7 +20,9 @@ namespace AZ
|
||||
char resolvedPath[AZ_MAX_PATH_LEN];
|
||||
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
DWORD fileAttributes = GetFileAttributesA(resolvedPath);
|
||||
wchar_t resolvedPathW[AZ_MAX_PATH_LEN];
|
||||
AZStd::to_wstring(resolvedPathW, AZ_MAX_PATH_LEN, resolvedPath);
|
||||
DWORD fileAttributes = GetFileAttributesW(resolvedPathW);
|
||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
return false;
|
||||
@@ -174,7 +176,7 @@ namespace AZ
|
||||
|
||||
bool LocalFileIO::IsAbsolutePath(const char* path) const
|
||||
{
|
||||
char drive[16];
|
||||
char drive[16] = { 0 };
|
||||
_splitpath_s(path, drive, 16, nullptr, 0, nullptr, 0, nullptr, 0);
|
||||
return strlen(drive) > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user