Compute scrcpy directory manually
The function dirname() does not work correctly everywhere with non-ASCII characters. Fixes #2619 <https://github.com/Genymobile/scrcpy/issues/2619>
This commit is contained in:
parent
b5e98db635
commit
4d6dd9d281
1 changed files with 14 additions and 1 deletions
|
@ -60,7 +60,20 @@ get_server_path(void) {
|
||||||
// not found, use current directory
|
// not found, use current directory
|
||||||
return strdup(SERVER_FILENAME);
|
return strdup(SERVER_FILENAME);
|
||||||
}
|
}
|
||||||
char *dir = dirname(executable_path);
|
|
||||||
|
// dirname() does not work correctly everywhere, so get the parent
|
||||||
|
// directory manually.
|
||||||
|
// See <https://github.com/Genymobile/scrcpy/issues/2619>
|
||||||
|
char *p = strrchr(executable_path, PATH_SEPARATOR);
|
||||||
|
if (!p) {
|
||||||
|
LOGE("Unexpected executable path: \"%s\" (it should contain a '%c')",
|
||||||
|
executable_path, PATH_SEPARATOR);
|
||||||
|
free(executable_path);
|
||||||
|
return strdup(SERVER_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
*p = '\0'; // modify executable_path in place
|
||||||
|
char *dir = executable_path;
|
||||||
size_t dirlen = strlen(dir);
|
size_t dirlen = strlen(dir);
|
||||||
|
|
||||||
// sizeof(SERVER_FILENAME) gives statically the size including the null byte
|
// sizeof(SERVER_FILENAME) gives statically the size including the null byte
|
||||||
|
|
Loading…
Reference in a new issue