mirror of
https://github.com/open-goal/jak-project
synced 2026-07-08 14:36:52 -04:00
Update function names and file path stripping
This commit is contained in:
@@ -8,26 +8,26 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
std::string FileUtil::GetExecutablePath() {
|
||||
std::string FileUtil::GetProjectPath() {
|
||||
#ifdef _WIN32
|
||||
char buffer[FILENAME_MAX];
|
||||
GetModuleFileNameA(NULL, buffer, FILENAME_MAX);
|
||||
std::string::size_type pos =
|
||||
std::string(buffer).find_last_of("/\\"); // Strip executable from file path
|
||||
return std::string(buffer).substr(0, pos);
|
||||
std::string(buffer).rfind("\\jak-project\\"); // Strip file path down to \jak-project\ directory
|
||||
return std::string(buffer).substr(0, pos + 12); // + 12 to include "\jak-project" in the returned filepath
|
||||
#else // do Linux stuff
|
||||
char buffer[FILENAME_MAX];
|
||||
readlink("/proc/self/exe", buffer,
|
||||
FILENAME_MAX); // /proc/self acts like a "virtual folder" containing information about
|
||||
// the current process
|
||||
std::string::size_type pos =
|
||||
std::string(buffer).find_last_of("/\\"); // Strip executable from file path
|
||||
return std::string(buffer).substr(0, pos);
|
||||
std::string(buffer).find_last_of("/jak-project/"); // Strip file path down to /jak-project/ directory
|
||||
return std::string(buffer).substr(0, pos + 12); // + 12 to include "/jak-project" in the returned filepath
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string FileUtil::get_file_path(const std::vector<std::string>& input) {
|
||||
std::string currentPath = FileUtil::GetExecutablePath();
|
||||
std::string currentPath = FileUtil::GetProjectPath();
|
||||
char dirSeparator;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
#include <vector>
|
||||
|
||||
namespace FileUtil {
|
||||
std::string GetExecutablePath();
|
||||
std::string GetProjectPath();
|
||||
std::string get_file_path(const std::vector<std::string>& input);
|
||||
} // namespace FileUtil
|
||||
|
||||
Reference in New Issue
Block a user