Add addition and subtraction for integers, build macros, dgo building, and build/load test (#35)

* see if math works on windows

* add dgo

* windows debug

* windows debug 2

* one more debug try

* add extra debug print and change logic for slashes

* update

* again

* try again

* remove build game

* remove build game

* add back build-game

* remove runtime from test

* test

* reduce number of files

* go to c++ 14

* big stacks

* increase stack size again

* clean up cmake files
This commit is contained in:
water111
2020-09-12 20:41:12 -04:00
committed by GitHub
parent d56540f8c0
commit 90a7e9b4b9
36 changed files with 1133 additions and 27 deletions
+12 -7
View File
@@ -9,26 +9,29 @@
#include <Windows.h>
#else
#include <unistd.h>
#include <cstring>
#endif
std::string file_util::get_project_path() {
#ifdef _WIN32
char buffer[FILENAME_MAX];
GetModuleFileNameA(NULL, buffer, FILENAME_MAX);
std::string::size_type pos = std::string(buffer).rfind(
"\\jak-project\\"); // Strip file path down to \jak-project\ directory
printf("using path %s\n", buffer);
std::string::size_type pos =
std::string(buffer).rfind("jak-project"); // Strip file path down to \jak-project\ directory
printf("rfind returned %lld\n", pos);
return std::string(buffer).substr(
0, pos + 12); // + 12 to include "\jak-project" in the returned filepath
0, pos + 11); // + 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).rfind(
"/jak-project/"); // Strip file path down to /jak-project/ directory
std::string::size_type 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
0, pos + 11); // + 12 to include "/jak-project" in the returned filepath
#endif
}
@@ -76,7 +79,8 @@ void file_util::write_text_file(const std::string& file_name, const std::string&
std::vector<uint8_t> file_util::read_binary_file(const std::string& filename) {
auto fp = fopen(filename.c_str(), "rb");
if (!fp)
throw std::runtime_error("File " + filename + " cannot be opened");
throw std::runtime_error("File " + filename +
" cannot be opened: " + std::string(strerror(errno)));
fseek(fp, 0, SEEK_END);
auto len = ftell(fp);
rewind(fp);
@@ -87,6 +91,7 @@ std::vector<uint8_t> file_util::read_binary_file(const std::string& filename) {
if (fread(data.data(), len, 1, fp) != 1) {
throw std::runtime_error("File " + filename + " cannot be read");
}
fclose(fp);
return data;
}