Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofFilePath::ofGetAppName() #8181

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions libs/openFrameworks/utils/ofFileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,26 @@ class ofFilePath {
static of::filesystem::path getCurrentExeDirFS();
static std::string getCurrentExeDir();

/// Get the App name of the running binary
///
/// \param strip_debug removes a trailing "Debug" if present
/// \returns the App name as native string
static const auto getAppName(bool strip_debug = true) {
auto name = ofFilePath::getCurrentExePathFS().filename().native();
#if defined(TARGET_OSX)
auto debug_suffix = std::filesystem::path("Debug").native();
#else
auto debug_suffix = std::filesystem::path("_debug").native();
#endif
auto dbsize = debug_suffix.size();
if (strip_debug) {
if (name.size() > dbsize && name.compare(name.size() -dbsize , dbsize, debug_suffix) == 0) {
name.erase(name.size() - dbsize);
}
}
return name;
}

/// Get the absolute path to the user's home directory.
///
/// Mac OSX: /Users/<username>
Expand Down