Review formating

This commit is contained in:
Ray 2022-01-10 13:54:51 +01:00
parent a6aa5a1e4c
commit b4e0ed6007
2 changed files with 16 additions and 16 deletions

View file

@ -160,8 +160,7 @@
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext. #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
#endif #endif
// Platform specific defines to handle GetApplicationDirectory()
// platform specific defines to handle GetApplicationDirectory
#if defined (PLATFORM_DESKTOP) #if defined (PLATFORM_DESKTOP)
#if defined(_WIN32) #if defined(_WIN32)
#ifndef MAX_PATH #ifndef MAX_PATH
@ -183,13 +182,13 @@
int WideCharToMultiByte(unsigned int cp, unsigned long flags, const unsigned short *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); int WideCharToMultiByte(unsigned int cp, unsigned long flags, const unsigned short *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
const char PathDelim = '\\'; const char pathDelim = '\\';
#elif defined(__linux__) #elif defined(__linux__)
#include <unistd.h> #include <unistd.h>
const char PathDelim = '/'; const char pathDelim = '/';
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/syslimits.h> #include <sys/syslimits.h>
const char PathDelim = '/'; const char pathDelim = '/';
#endif // OSs #endif // OSs
#endif // PLATFORM_DESKTOP #endif // PLATFORM_DESKTOP
@ -3012,6 +3011,7 @@ const char* GetApplicationDirectory(void)
GetModuleFileNameFunc getModuleFileNameExWPtr = NULL; GetModuleFileNameFunc getModuleFileNameExWPtr = NULL;
void *lib = LoadLibrary(L"psapi.dll"); void *lib = LoadLibrary(L"psapi.dll");
if (lib == NULL) if (lib == NULL)
{ {
appDir[0] = '\\'; appDir[0] = '\\';
@ -3034,7 +3034,6 @@ const char* GetApplicationDirectory(void)
#if defined (UNICODE) #if defined (UNICODE)
unsigned short widePath[MAX_PATH]; unsigned short widePath[MAX_PATH];
len = getModuleFileNameExWPtr(GetCurrentProcess(), NULL, widePath, MAX_PATH); len = getModuleFileNameExWPtr(GetCurrentProcess(), NULL, widePath, MAX_PATH);
len = WideCharToMultiByte(0, 0, widePath, len, appDir, MAX_PATH, NULL, NULL); len = WideCharToMultiByte(0, 0, widePath, len, appDir, MAX_PATH, NULL, NULL);
#else #else
len = getModuleFileNameExWPtr(GetCurrentProcess(), NULL, appDir, MAX_PATH); len = getModuleFileNameExWPtr(GetCurrentProcess(), NULL, appDir, MAX_PATH);
@ -3051,12 +3050,13 @@ const char* GetApplicationDirectory(void)
} }
} }
} }
FreeLibrary(lib); FreeLibrary(lib);
} }
#elif defined(__linux__) #elif defined(__linux__)
unsigned int size = sizeof(appDir); unsigned int size = sizeof(appDir);
ssize_t len = readlink("/proc/self/exe", appDir, size); ssize_t len = readlink("/proc/self/exe", appDir, size);
if (len > 0) if (len > 0)
{ {
for (int i = len; i >= 0; --i) for (int i = len; i >= 0; --i)