Skip to content

Commit 266cee0

Browse files
authored
Merge pull request #8181 from artificiel/getAppName
ofFilePath::ofGetAppName()
2 parents 04a7c4d + 79c89c6 commit 266cee0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

libs/openFrameworks/utils/ofFileUtils.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,26 @@ class ofFilePath {
447447
static of::filesystem::path getCurrentExeDirFS();
448448
static std::string getCurrentExeDir();
449449

450+
/// Get the App name of the running binary
451+
///
452+
/// \param strip_debug removes a trailing "Debug" if present
453+
/// \returns the App name as native string
454+
static const auto getAppName(bool strip_debug = true) {
455+
auto name = ofFilePath::getCurrentExePathFS().filename().native();
456+
#if defined(TARGET_OSX)
457+
auto debug_suffix = std::filesystem::path("Debug").native();
458+
#else
459+
auto debug_suffix = std::filesystem::path("_debug").native();
460+
#endif
461+
auto dbsize = debug_suffix.size();
462+
if (strip_debug) {
463+
if (name.size() > dbsize && name.compare(name.size() -dbsize , dbsize, debug_suffix) == 0) {
464+
name.erase(name.size() - dbsize);
465+
}
466+
}
467+
return name;
468+
}
469+
450470
/// Get the absolute path to the user's home directory.
451471
///
452472
/// Mac OSX: /Users/<username>

0 commit comments

Comments
 (0)