mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-16 22:01:11 +00:00
Display an error if the mapping cannot be found. Fix mappings passed with absolute paths.
This commit is contained in:
committed by
Iwan Timmer
parent
8d7b2d94be
commit
cd954e4935
+11
-2
@@ -40,7 +40,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#define MOONLIGHT_PATH "/moonlight/"
|
#define MOONLIGHT_PATH "/moonlight/"
|
||||||
#define USER_PATHS ":~/.moonlight:./"
|
#define USER_PATHS ":~/.moonlight/:./"
|
||||||
|
|
||||||
static void applist(const char* address) {
|
static void applist(const char* address) {
|
||||||
struct app_list* list = client_applist(address);
|
struct app_list* list = client_applist(address);
|
||||||
@@ -98,6 +98,11 @@ static void help() {
|
|||||||
char* get_path(char* name) {
|
char* get_path(char* name) {
|
||||||
const char *xdg_data_dirs = getenv("XDG_DATA_DIRS");
|
const char *xdg_data_dirs = getenv("XDG_DATA_DIRS");
|
||||||
char *data_dirs;
|
char *data_dirs;
|
||||||
|
|
||||||
|
if (access(name, R_OK) != -1) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
if (!xdg_data_dirs)
|
if (!xdg_data_dirs)
|
||||||
data_dirs = "/usr/share:/usr/local/share:" USER_PATHS;
|
data_dirs = "/usr/share:/usr/local/share:" USER_PATHS;
|
||||||
else {
|
else {
|
||||||
@@ -122,7 +127,7 @@ char* get_path(char* name) {
|
|||||||
else
|
else
|
||||||
sprintf(path+length, "%s", name);
|
sprintf(path+length, "%s", name);
|
||||||
|
|
||||||
if(access(path, F_OK) != -1)
|
if(access(path, R_OK) != -1)
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
data_dirs = end + 1;
|
data_dirs = end + 1;
|
||||||
@@ -209,6 +214,10 @@ int main(int argc, char* argv[]) {
|
|||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
mapping = get_path(optarg);
|
mapping = get_path(optarg);
|
||||||
|
if (mapping == NULL) {
|
||||||
|
fprintf(stderr, "Unable to open custom mapping file: %s\n", optarg);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
sops = false;
|
sops = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user