UI: Add obs_frontend_get_current_profile_path()

Returns the path of the current profile's location on the filesystem.
This commit is contained in:
tt2468 2021-04-13 16:49:01 -07:00 committed by Dillon Pentz
parent 53a8a326da
commit 9ca70f4470
5 changed files with 25 additions and 0 deletions

View file

@ -238,6 +238,16 @@ struct OBSStudioAPI : obs_frontend_callbacks {
return bstrdup(name);
}
char *obs_frontend_get_current_profile_path(void) override
{
char profilePath[512];
int ret = GetProfilePath(profilePath, sizeof(profilePath), "");
if (ret <= 0)
return nullptr;
return bstrdup(profilePath);
}
void obs_frontend_set_current_profile(const char *profile) override
{
QList<QAction *> menuActions = main->ui->profileMenu->actions();

View file

@ -204,6 +204,12 @@ char *obs_frontend_get_current_profile(void)
: nullptr;
}
char *obs_frontend_get_current_profile_path(void)
{
return !!callbacks_valid() ? c->obs_frontend_get_current_profile_path()
: nullptr;
}
void obs_frontend_set_current_profile(const char *profile)
{
if (callbacks_valid())

View file

@ -117,6 +117,7 @@ EXPORT bool obs_frontend_add_scene_collection(const char *name);
EXPORT char **obs_frontend_get_profiles(void);
EXPORT char *obs_frontend_get_current_profile(void);
EXPORT char *obs_frontend_get_current_profile_path(void);
EXPORT void obs_frontend_set_current_profile(const char *profile);
typedef void (*obs_frontend_cb)(void *private_data);

View file

@ -37,6 +37,7 @@ struct obs_frontend_callbacks {
virtual void
obs_frontend_get_profiles(std::vector<std::string> &strings) = 0;
virtual char *obs_frontend_get_current_profile(void) = 0;
virtual char *obs_frontend_get_current_profile_path(void) = 0;
virtual void obs_frontend_set_current_profile(const char *profile) = 0;
virtual void obs_frontend_streaming_start(void) = 0;

View file

@ -314,6 +314,13 @@ Functions
---------------------------------------
.. function:: char *obs_frontend_get_current_profile_path(void)
:return: A new pointer to the current profile's path on the filesystem. Free
with :c:func:`bfree()`.
---------------------------------------
.. function:: void obs_frontend_set_current_profile(const char *profile)
:param profile: Name of the profile to activate.