From 31c0976e7a18a401ac6bf8cc85ba21313b0499b3 Mon Sep 17 00:00:00 2001 From: loki Date: Wed, 4 Dec 2019 22:58:31 +0100 Subject: [PATCH] test for the existance of a file before reading from it --- .gitmodules | 4 ++-- CMakeLists.txt | 5 +++-- nvhttp.cpp | 12 ++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 576591c2..ce0ede82 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "moonlight-common-c"] path = moonlight-common-c - url = git@github.com:moonlight-stream/moonlight-common-c.git + url = https://github.com/moonlight-stream/moonlight-common-c.git [submodule "Simple-Web-Server"] path = Simple-Web-Server - url = git@github.com:loki-47-6F-64/Simple-Web-Server.git + url = https://github.com/loki-47-6F-64/Simple-Web-Server.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2450bf5a..47c8f232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,9 +56,11 @@ include_directories( find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) find_package(FFmpeg REQUIRED) + +#FIXME: libX11 is Linux only find_package(X11 REQUIRED) -list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized) +list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) if("x${BUILD_TYPE}" STREQUAL "xDEBUG") list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3) @@ -80,7 +82,6 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES pulse pulse-simple - #libpulse should be found with package_find opus) add_definitions(-DSUNSHINE_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets") diff --git a/nvhttp.cpp b/nvhttp.cpp index 6db5b1a0..79276e24 100644 --- a/nvhttp.cpp +++ b/nvhttp.cpp @@ -2,9 +2,8 @@ // Created by loki on 6/3/19. // -#include "nvhttp.h" - #include +#include #include #include @@ -19,6 +18,8 @@ #include "config.h" #include "utility.h" #include "stream.h" +#include "nvhttp.h" + namespace nvhttp { using namespace std::literals; @@ -28,6 +29,7 @@ constexpr auto PORT_HTTPS = 47984; constexpr auto VERSION = "7.1.415.0"; constexpr auto GFE_VERSION = "2.0.0.1"; +namespace fs = std::filesystem; namespace pt = boost::property_tree; std::string read_file(const char *path); @@ -91,6 +93,12 @@ void save_devices() { } void load_devices() { + auto file_devices = fs::current_path() / config::nvhttp.file_devices; + + if(!fs::exists(file_devices)) { + return; + } + pt::ptree root; try { pt::read_json(config::nvhttp.file_devices, root);