Get env in windows correctly
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
78a320a763
commit
f9786e5034
1 changed files with 10 additions and 0 deletions
|
@ -6,11 +6,13 @@
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <SDL2/SDL_timer.h>
|
#include <SDL2/SDL_timer.h>
|
||||||
|
#include <SDL2/SDL_platform.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/net.h"
|
#include "util/net.h"
|
||||||
|
#include "util/str_util.h"
|
||||||
|
|
||||||
#define SOCKET_NAME "scrcpy"
|
#define SOCKET_NAME "scrcpy"
|
||||||
#define SERVER_FILENAME "scrcpy-server"
|
#define SERVER_FILENAME "scrcpy-server"
|
||||||
|
@ -20,10 +22,18 @@
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_server_path(void) {
|
get_server_path(void) {
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
const wchar_t *server_path_env = _wgetenv(L"SCRCPY_SERVER_PATH");
|
||||||
|
#else
|
||||||
const char *server_path_env = getenv("SCRCPY_SERVER_PATH");
|
const char *server_path_env = getenv("SCRCPY_SERVER_PATH");
|
||||||
|
#endif
|
||||||
if (server_path_env) {
|
if (server_path_env) {
|
||||||
// if the envvar is set, use it
|
// if the envvar is set, use it
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
char *server_path = utf8_from_wide_char(server_path_env);
|
||||||
|
#else
|
||||||
char *server_path = SDL_strdup(server_path_env);
|
char *server_path = SDL_strdup(server_path_env);
|
||||||
|
#endif
|
||||||
if (!server_path) {
|
if (!server_path) {
|
||||||
LOGE("Could not allocate memory");
|
LOGE("Could not allocate memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue