File tree 4 files changed +32
-3
lines changed
4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ Resources/[Pp]resets
21
21
* .pkg
22
22
** .pkg
23
23
installer /macOS /[Pp ]ayload /*
24
+ .vscode
24
25
.vscode /*
25
26
! .vscode /settings.json
26
27
! .vscode /tasks.json
Original file line number Diff line number Diff line change 10
10
#include < marvin/utils/marvin_Utils.h>
11
11
12
12
#if defined(MARVIN_MACOS)
13
-
13
+ # include < mach-o/dyld.h >
14
14
#elif defined(MARVIN_WINDOWS)
15
15
#include < windows.h>
16
16
#elif defined(MARVIN_LINUX)
17
17
18
18
#endif
19
19
namespace marvin ::utils {
20
20
std::optional<std::string> getCurrentExecutablePath () {
21
+ constexpr static auto maxLength{ 512 };
21
22
#if defined(MARVIN_MACOS)
22
- return {};
23
+ char data[maxLength];
24
+ std::uint32_t length{ sizeof (data) };
25
+ const auto resCode = _NSGetExecutablePath (data, &length);
26
+ if (resCode != 0 ) return {};
27
+ std::string res = data;
28
+ return res;
23
29
#elif defined(MARVIN_WINDOWS)
24
- constexpr static auto maxLength{ 512 };
25
30
char data[maxLength];
26
31
auto dest = (LPSTR)data;
27
32
GetModuleFileName (nullptr , dest, maxLength);
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ set(MARVIN_TEST_SOURCE
15
15
${CMAKE_CURRENT_SOURCE_DIR} /math/marvin_LeakyIntegratorTests.cpp
16
16
${CMAKE_CURRENT_SOURCE_DIR} /math/marvin_VecOpsTests.cpp
17
17
${CMAKE_CURRENT_SOURCE_DIR} /math/marvin_WindowedSincInterpolatorTests.cpp
18
+ ${CMAKE_CURRENT_SOURCE_DIR} /utils/marvin_UtilsTests.cpp
18
19
${CMAKE_CURRENT_SOURCE_DIR} /utils/marvin_SmoothedValueTests.cpp
19
20
${CMAKE_CURRENT_SOURCE_DIR} /utils/marvin_RandomTests.cpp
20
21
${CMAKE_CURRENT_SOURCE_DIR} /utils/marvin_FIFOTests.cpp
Original file line number Diff line number Diff line change
1
+ // ========================================================================================================
2
+ // _______ _______ ______ ___ ___ _______ _______
3
+ // | | | _ | __ \ | |_ _| | |
4
+ // | | | < | |_| |_| |
5
+ // |__|_|__|___|___|___|__|\_____/|_______|__|____|
6
+ //
7
+ // This file is part of the Marvin open source library and is licensed under the terms of the MIT License.
8
+ //
9
+ // ========================================================================================================
10
+
11
+ #include < marvin/utils/marvin_Utils.h>
12
+ #include < catch2/catch_test_macros.hpp>
13
+ #include < catch2/matchers/catch_matchers_floating_point.hpp>
14
+ #include < iostream>
15
+ namespace marvin ::testing {
16
+ TEST_CASE (" Test getCurrentExecutablePath()" ) {
17
+ const auto pathRes = utils::getCurrentExecutablePath ();
18
+ REQUIRE (pathRes);
19
+ std::cout << *pathRes << " \n " ;
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments