From 1f1548929d7df0485c5b1e596097abfa58383824 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 6 Sep 2020 12:56:20 -0500 Subject: [PATCH] Use working directory for all file accesses, some old file accesses always used the executable directory --- .../LEDStripControllerDetect.cpp | 15 +-------------- RGBController/E131ControllerDetect.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/Controllers/LEDStripController/LEDStripControllerDetect.cpp b/Controllers/LEDStripController/LEDStripControllerDetect.cpp index 3276bc92d..21ff4338f 100644 --- a/Controllers/LEDStripController/LEDStripControllerDetect.cpp +++ b/Controllers/LEDStripController/LEDStripControllerDetect.cpp @@ -30,24 +30,11 @@ void DetectLEDStripControllers(std::vector &rgb_controllers) LEDStripController* new_ledstrip; RGBController_LEDStrip* new_controller; - //Get file path in executable directory std::ifstream infile; - char filename[2048]; char arg1[64]; -#ifdef WIN32 - GetModuleFileName(NULL, filename, 2048); - strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str()); - strcat(filename, "\\ledstrip.txt"); -#else - snprintf(arg1, 64, "/proc/%d/exe", getpid()); - readlink(arg1, filename, 1024); - strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str()); - strcat(filename, "/ledstrip.txt"); -#endif - //Open settings file - infile.open(filename); + infile.open("ledstrip.txt"); if (infile.good()) { diff --git a/RGBController/E131ControllerDetect.cpp b/RGBController/E131ControllerDetect.cpp index c22c24c6e..d288f5c49 100644 --- a/RGBController/E131ControllerDetect.cpp +++ b/RGBController/E131ControllerDetect.cpp @@ -35,22 +35,9 @@ void DetectE131Controllers(std::vector &rgb_controllers) { RGBController_E131* new_controller; - //Get file path in executable directory std::ifstream infile; - char filename[2048]; char arg1[64]; -#ifdef WIN32 - GetModuleFileName(NULL, filename, 2048); - strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str()); - strcat(filename, "\\e131.txt"); -#else - snprintf(arg1, 64, "/proc/%d/exe", getpid()); - readlink(arg1, filename, 1024); - strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str()); - strcat(filename, "/e131.txt"); -#endif - E131Device dev; std::vector devices; @@ -66,7 +53,7 @@ void DetectE131Controllers(std::vector &rgb_controllers) dev.matrix_height = 0; //Open settings file - infile.open(filename); + infile.open("e131.txt"); if (infile.good()) {