Upload new files

This commit is contained in:
blahpy
2020-09-09 16:54:16 +12:00
parent 2075dd66b6
commit eb886d0c45
6 changed files with 57 additions and 1 deletions
+3
View File
@@ -42,6 +42,9 @@ add_subdirectory(asset_tool)
# build type_system library for compiler/decompiler
add_subdirectory(common/type_system)
# build common_util library
add_subdirectory(common/util)
# build decompiler
add_subdirectory(decompiler)
+5
View File
@@ -0,0 +1,5 @@
add_library(common_util
SHARED
FileUtil.cpp)
target_link_libraries(common_util fmt)
+26
View File
@@ -0,0 +1,26 @@
#include "FileUtil.h"
#include <iostream>
#include <filesystem>
std::string FileUtil::get_file_path(std::string input[]) {
int arrSize = std::sizeof(input);
std::string currentPath = std::filesystem::current_path();
char dirSeparator;
#ifdef _WIN32
dirSeparator = '\';
#else
dirSeparator = '/';
#endif
std::string filePath = currentPath;
for (int i = 0; i < arrSize; i++) {
if (arrSize = i+1) {
filePath = filePath << input[i];
} else {
filePath = filePath << input[i] << dirSeparator;
}
}
return filePath;
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <string>
namespace FileUtil
{
class FileUtil
{
public:
std::string get_file_path();
};
}
+1 -1
View File
@@ -14,7 +14,7 @@ add_executable(goalc-test
test_emitter_loads_and_store.cpp
test_emitter_xmm32.cpp
test_emitter_integer_math.cpp
)
"test_common_util.cpp")
IF (WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+11
View File
@@ -0,0 +1,11 @@
#include "common/util/FileUtil.h"
#include <iostream>
#include "gtest/gtest.h"
TEST(test, test) {
std::string test[] = {"cabbage", "banana", "apple"};
std::cout << FileUtil::get_file_path(test) << std::endl;
EXPECT_TRUE(true);
}