summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/src/filepath.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bx/src/filepath.cpp')
-rw-r--r--3rdparty/bx/src/filepath.cpp62
1 files changed, 17 insertions, 45 deletions
diff --git a/3rdparty/bx/src/filepath.cpp b/3rdparty/bx/src/filepath.cpp
index a675aaae736..892bf80e48c 100644
--- a/3rdparty/bx/src/filepath.cpp
+++ b/3rdparty/bx/src/filepath.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2023 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx/blob/master/LICENSE
*/
@@ -16,12 +16,7 @@
#endif // !BX_CRT_NONE
#if BX_PLATFORM_WINDOWS
-#if !defined(GetModuleFileName)
-extern "C" __declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void* _module, char* _outFilePath, unsigned long _size);
-#endif
-extern "C" __declspec(dllimport) unsigned long __stdcall GetTempPathA(unsigned long _max, char* _outFilePath);
-#elif BX_PLATFORM_OSX
-extern "C" int _NSGetExecutablePath(char* _buf, uint32_t* _bufSize);
+extern "C" __declspec(dllimport) unsigned long __stdcall GetTempPathA(unsigned long _max, char* _ptr);
#endif // BX_PLATFORM_WINDOWS
namespace bx
@@ -185,7 +180,7 @@ namespace bx
return ::_getcwd(_buffer, (int32_t)_size);
#else
return ::getcwd(_buffer, _size);
-#endif // BX_PLATFORM_*
+#endif // BX_COMPILER_
}
static bool getCurrentPath(char* _out, uint32_t* _inOutSize)
@@ -200,35 +195,6 @@ namespace bx
return false;
}
- static bool getExecutablePath(char* _out, uint32_t* _inOutSize)
- {
-#if BX_PLATFORM_WINDOWS
- uint32_t len = ::GetModuleFileNameA(NULL, _out, *_inOutSize);
- bool result = len != 0 && len < *_inOutSize;
- *_inOutSize = len;
- return result;
-#elif BX_PLATFORM_LINUX
- char tmp[64];
- snprintf(tmp, sizeof(tmp), "/proc/%d/exe", getpid() );
- ssize_t result = readlink(tmp, _out, *_inOutSize);
-
- if (-1 < result)
- {
- *_inOutSize = uint32_t(result);
- return true;
- }
-#elif BX_PLATFORM_OSX
- uint32_t len = *_inOutSize;
- bool result = _NSGetExecutablePath(_out, &len);
- if (0 == result)
- {
- return true;
- }
-#endif // BX_PLATFORM_*
-
- return false;
- }
-
static bool getHomePath(char* _out, uint32_t* _inOutSize)
{
return false
@@ -321,21 +287,27 @@ namespace bx
void FilePath::set(Dir::Enum _dir)
{
- bool ok = false;
char tmp[kMaxFilePath];
uint32_t len = BX_COUNTOF(tmp);
switch (_dir)
{
- case Dir::Current: ok = getCurrentPath(tmp, &len); break;
- case Dir::Executable: ok = getExecutablePath(tmp, &len); break;
- case Dir::Home: ok = getHomePath(tmp, &len); break;
- case Dir::Temp: ok = getTempPath(tmp, &len); break;
+ case Dir::Current:
+ getCurrentPath(tmp, &len);
+ break;
- default: break;
- }
+ case Dir::Temp:
+ getTempPath(tmp, &len);
+ break;
- len = ok ? len : 0;
+ case Dir::Home:
+ getHomePath(tmp, &len);
+ break;
+
+ default:
+ len = 0;
+ break;
+ }
set(StringView(tmp, len) );
}