Skip to content

Commit 1f15489

Browse files
Use working directory for all file accesses, some old file accesses always used the executable directory
1 parent 3e62c91 commit 1f15489

2 files changed

Lines changed: 2 additions & 28 deletions

File tree

Controllers/LEDStripController/LEDStripControllerDetect.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,11 @@ void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
3030
LEDStripController* new_ledstrip;
3131
RGBController_LEDStrip* new_controller;
3232

33-
//Get file path in executable directory
3433
std::ifstream infile;
35-
char filename[2048];
3634
char arg1[64];
3735

38-
#ifdef WIN32
39-
GetModuleFileName(NULL, filename, 2048);
40-
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
41-
strcat(filename, "\\ledstrip.txt");
42-
#else
43-
snprintf(arg1, 64, "/proc/%d/exe", getpid());
44-
readlink(arg1, filename, 1024);
45-
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
46-
strcat(filename, "/ledstrip.txt");
47-
#endif
48-
4936
//Open settings file
50-
infile.open(filename);
37+
infile.open("ledstrip.txt");
5138

5239
if (infile.good())
5340
{

RGBController/E131ControllerDetect.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,9 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
3535
{
3636
RGBController_E131* new_controller;
3737

38-
//Get file path in executable directory
3938
std::ifstream infile;
40-
char filename[2048];
4139
char arg1[64];
4240

43-
#ifdef WIN32
44-
GetModuleFileName(NULL, filename, 2048);
45-
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
46-
strcat(filename, "\\e131.txt");
47-
#else
48-
snprintf(arg1, 64, "/proc/%d/exe", getpid());
49-
readlink(arg1, filename, 1024);
50-
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
51-
strcat(filename, "/e131.txt");
52-
#endif
53-
5441
E131Device dev;
5542
std::vector<E131Device> devices;
5643

@@ -66,7 +53,7 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
6653
dev.matrix_height = 0;
6754

6855
//Open settings file
69-
infile.open(filename);
56+
infile.open("e131.txt");
7057

7158
if (infile.good())
7259
{

0 commit comments

Comments
 (0)