diff --git a/.gitignore b/.gitignore index 48f2dbc..b0e0ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Resources/[Pp]resets *.pkg **.pkg installer/macOS/[Pp]ayload/* +.vscode .vscode/* !.vscode/settings.json !.vscode/tasks.json diff --git a/source/utils/marvin_Utils.cpp b/source/utils/marvin_Utils.cpp index 482b970..2e1e667 100644 --- a/source/utils/marvin_Utils.cpp +++ b/source/utils/marvin_Utils.cpp @@ -10,7 +10,7 @@ #include #if defined(MARVIN_MACOS) - +#include #elif defined(MARVIN_WINDOWS) #include #elif defined(MARVIN_LINUX) @@ -18,10 +18,15 @@ #endif namespace marvin::utils { std::optional getCurrentExecutablePath() { + constexpr static auto maxLength{ 512 }; #if defined(MARVIN_MACOS) - return {}; + char data[maxLength]; + std::uint32_t length{ sizeof(data) }; + const auto resCode = _NSGetExecutablePath(data, &length); + if(resCode != 0) return {}; + std::string res = data; + return res; #elif defined(MARVIN_WINDOWS) - constexpr static auto maxLength{ 512 }; char data[maxLength]; auto dest = (LPSTR)data; GetModuleFileName(nullptr, dest, maxLength); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c17247..58d9301 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,6 +15,7 @@ set(MARVIN_TEST_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/math/marvin_LeakyIntegratorTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/math/marvin_VecOpsTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/math/marvin_WindowedSincInterpolatorTests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/marvin_UtilsTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/utils/marvin_SmoothedValueTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/utils/marvin_RandomTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/utils/marvin_FIFOTests.cpp diff --git a/tests/utils/marvin_UtilsTests.cpp b/tests/utils/marvin_UtilsTests.cpp new file mode 100644 index 0000000..1c5c4a9 --- /dev/null +++ b/tests/utils/marvin_UtilsTests.cpp @@ -0,0 +1,22 @@ +// ======================================================================================================== +// _______ _______ ______ ___ ___ _______ _______ +// | | | _ | __ \ | |_ _| | | +// | | | < | |_| |_| | +// |__|_|__|___|___|___|__|\_____/|_______|__|____| +// +// This file is part of the Marvin open source library and is licensed under the terms of the MIT License. +// +// ======================================================================================================== + +#include +#include +#include +#include +namespace marvin::testing { + TEST_CASE("Test getCurrentExecutablePath()") { + const auto pathRes = utils::getCurrentExecutablePath(); + REQUIRE(pathRes); + std::cout << *pathRes << "\n"; + } + +}