mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 22:22:21 -04:00
Upload new files
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
add_library(common_util
|
||||
SHARED
|
||||
FileUtil.cpp)
|
||||
|
||||
target_link_libraries(common_util fmt)
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace FileUtil
|
||||
{
|
||||
class FileUtil
|
||||
{
|
||||
public:
|
||||
std::string get_file_path();
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user