Simplify fill_pathname_application_path
This commit is contained in:
parent
60e5858d51
commit
d94cc3af72
|
@ -1364,33 +1364,17 @@ void path_basedir_wrapper(char *s)
|
|||
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
||||
size_t fill_pathname_application_path(char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef __APPLE__
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
DWORD ret = 0;
|
||||
wchar_t wstr[PATH_MAX_LENGTH] = {0};
|
||||
#endif
|
||||
#ifdef __HAIKU__
|
||||
image_info info;
|
||||
int32_t cookie = 0;
|
||||
#endif
|
||||
(void)i;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
if (len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#ifdef LEGACY_WIN32
|
||||
ret = GetModuleFileNameA(NULL, s, len);
|
||||
DWORD ret = GetModuleFileNameA(NULL, s, len);
|
||||
#else
|
||||
ret = GetModuleFileNameW(NULL, wstr, ARRAY_SIZE(wstr));
|
||||
|
||||
wchar_t wstr[PATH_MAX_LENGTH] = {0};
|
||||
DWORD ret = GetModuleFileNameW(NULL, wstr, ARRAY_SIZE(wstr));
|
||||
if (*wstr)
|
||||
{
|
||||
char *str = utf16_to_utf8_string_alloc(wstr);
|
||||
|
||||
if (str)
|
||||
{
|
||||
strlcpy(s, str, len);
|
||||
|
@ -1401,6 +1385,7 @@ size_t fill_pathname_application_path(char *s, size_t len)
|
|||
s[ret] = '\0';
|
||||
return ret;
|
||||
#elif defined(__APPLE__)
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
if (bundle)
|
||||
{
|
||||
size_t rv = 0;
|
||||
|
@ -1429,26 +1414,23 @@ size_t fill_pathname_application_path(char *s, size_t len)
|
|||
CFRelease(bundle_url);
|
||||
return rv;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(__HAIKU__)
|
||||
image_info info;
|
||||
int32_t cookie = 0;
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
||||
{
|
||||
if (info.type == B_APP_IMAGE)
|
||||
{
|
||||
return strlcpy(s, info.name, len);
|
||||
}
|
||||
}
|
||||
#elif defined(__QNX__)
|
||||
char *buff = malloc(len);
|
||||
size_t rv = 0;
|
||||
|
||||
if (_cmdname(buff))
|
||||
rv = strlcpy(s, buff, len);
|
||||
|
||||
free(buff);
|
||||
return rv;
|
||||
#else
|
||||
{
|
||||
size_t i;
|
||||
static const char *exts[] = { "exe", "file", "path/a.out" };
|
||||
char link_path[255];
|
||||
pid_t pid = getpid();
|
||||
|
@ -1469,10 +1451,10 @@ size_t fill_pathname_application_path(char *s, size_t len)
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fill_pathname_application_dir(char *s, size_t len)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue