Skip to content

Commit

Permalink
Moved one-time-use method into code
Browse files Browse the repository at this point in the history
  • Loading branch information
X39 committed Feb 15, 2020
1 parent e6c82c2 commit 3317dd7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
31 changes: 14 additions & 17 deletions src/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ int console_width()
}


std::string get_working_dir()
{
#if defined(_WIN32) || defined(_WIN64)
char buffer[MAX_PATH];
_getcwd(buffer, MAX_PATH);
return std::string(buffer);
#elif defined(__GNUC__)
char buffer[PATH_MAX];
getcwd(buffer, PATH_MAX);
return std::string(buffer);
#else
#error "NO IMPLEMENTATION AVAILABLE"
#endif
}

bool isInLoadFileCliMode = false;

std::string arg_file_actual_path(std::string executable_path, std::string f)
Expand Down Expand Up @@ -144,8 +129,20 @@ int main(int argc, char** argv)
sigaction(SIGSEGV, &action_SIGSEGV, NULL);
#endif


auto executable_path = sqf::filesystem::sanitize(get_working_dir());
std::string executable_path;
{
#if defined(_WIN32) || defined(_WIN64)
char buffer[MAX_PATH];
_getcwd(buffer, MAX_PATH);
executable_path = sqf::filesystem::sanitize(buffer);
#elif defined(__GNUC__)
char buffer[PATH_MAX];
getcwd(buffer, PATH_MAX);
executable_path = sqf::filesystem::sanitize(buffer);
#else
#error "NO IMPLEMENTATION AVAILABLE"
#endif
}
TCLAP::CmdLine cmd("Emulates the ArmA-Series SQF environment.", ' ', std::string{VERSION_FULL} + " (" + g_GIT_SHA1 + ")\n");

TCLAP::ValueArg<std::string> cliFileArg("", "cli-file", "Allows to provide a file from which to load arguments from. If passed, all other arguments will be ignored! Each argument needs to be separated by line-feed. " RELPATHHINT, false, "", "PATH");
Expand Down
37 changes: 24 additions & 13 deletions src/dllexports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@
#include <execinfo.h>
#endif


extern "C" {

std::string get_working_dir()
{
std::string get_working_dir()
{
#if defined(_WIN32) || defined(_WIN64)
char buffer[MAX_PATH];
_getcwd(buffer, MAX_PATH);
return std::string(buffer);
char buffer[MAX_PATH];
_getcwd(buffer, MAX_PATH);
return std::string(buffer);
#elif defined(__GNUC__)
char buffer[PATH_MAX];
getcwd(buffer, PATH_MAX);
return std::string(buffer);
char buffer[PATH_MAX];
getcwd(buffer, PATH_MAX);
return std::string(buffer);
#else
#error "NO IMPLEMENTATION AVAILABLE"
#endif
}
}
extern "C" {
DLLEXPORT_PREFIX void sqfvm_init(unsigned long long limit)
{
sqfvm_virtualmachine = std::make_shared<sqf::virtualmachine>(sqfvm_exportstarget, limit);
Expand All @@ -52,7 +50,20 @@ extern "C" {
{
std::stringstream sstream;
bool err;
auto executable_path = get_working_dir();
std::string executable_path;
{
#if defined(_WIN32) || defined(_WIN64)
char buffer[MAX_PATH];
_getcwd(buffer, MAX_PATH);
executable_path = sqf::filesystem::sanitize(buffer);
#elif defined(__GNUC__)
char buffer[PATH_MAX];
getcwd(buffer, PATH_MAX);
executable_path = sqf::filesystem::sanitize(buffer);
#else
#error "NO IMPLEMENTATION AVAILABLE"
#endif
}
auto inputAfterPP = sqfvm_virtualmachine->preprocess(code, err, "__libraryfeed.sqf");
if (!err)
{
Expand Down

0 comments on commit 3317dd7

Please sign in to comment.