Selaa lähdekoodia

UI: Add obs_frontend_get_current_profile_path()

Returns the path of the current profile's location on the filesystem.
tt2468 4 vuotta sitten
vanhempi
sitoutus
9ca70f4470

+ 10 - 0
UI/api-interface.cpp

@@ -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();

+ 6 - 0
UI/obs-frontend-api/obs-frontend-api.cpp

@@ -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())

+ 1 - 0
UI/obs-frontend-api/obs-frontend-api.h

@@ -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);

+ 1 - 0
UI/obs-frontend-api/obs-frontend-internal.hpp

@@ -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;

+ 7 - 0
docs/sphinx/reference-frontend-api.rst

@@ -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.