Skip to content

Commit

Permalink
Fix exe path logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopicchi committed May 3, 2023
1 parent af4666f commit c432c03
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Converter/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@


#include <iostream>
#include <execution>
#include <string>

#ifdef WINDOWS
#include <windows.h>
#else
#include <limits.h>
#include <unistd.h>
#endif

#include "unsuck/unsuck.hpp"
#include "chunker_countsort_laszip.h"
Expand Down Expand Up @@ -494,6 +500,17 @@ void generatePage(string exePath, string pagedir, string pagename) {

#include "HierarchyBuilder.h"

std::string getExePath() {
#ifdef WINDOWS
char result[ MAX_PATH ];
return std::string(result, GetModuleFileName(NULL, result, MAX_PATH));
#else
char result[ PATH_MAX ];
ssize_t count = readlink("/proc/self/exe", result, PATH_MAX);
return std::string(result, (count > 0) ? count : 0);
#endif
}

int main(int argc, char** argv) {


Expand All @@ -512,7 +529,8 @@ int main(int argc, char** argv) {

double tStart = now();

auto exePath = fs::canonical(fs::absolute(argv[0])).parent_path().string();
auto exePath = getExePath();
cout << "#exe path: " << exePath << endl;

launchMemoryChecker(2 * 1024, 0.1);
auto cpuData = getCpuData();
Expand Down Expand Up @@ -566,4 +584,4 @@ int main(int argc, char** argv) {


return 0;
}
}

0 comments on commit c432c03

Please sign in to comment.