Skip to content

Commit 1dea7e2

Browse files
committed
Set local file browse path to last used file dir
1 parent e3d2bac commit 1dea7e2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

obs-browser/main-source.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
******************************************************************************/
1717

1818
#include <obs-module.h>
19+
#include <util/dstr.h>
1920

2021
#include "browser-source.hpp"
2122
#include "browser-manager.hpp"
@@ -55,19 +56,33 @@ static bool is_local_file_modified(obs_properties_t *props,
5556
return true;
5657
}
5758

58-
static obs_properties_t *browser_source_get_properties(void *)
59+
static obs_properties_t *browser_source_get_properties(void *data)
5960
{
6061
obs_properties_t *props = obs_properties_create();
62+
struct dstr path = { 0 };
63+
BrowserSource *bs = static_cast<BrowserSource *>(data);
6164

6265
obs_properties_set_flags(props, OBS_PROPERTIES_DEFER_UPDATE);
6366
// use this when obs allows non-readonly paths
6467
obs_property_t *prop = obs_properties_add_bool(props, "is_local_file",
6568
obs_module_text("Local file"));
6669

70+
if (bs && bs->GetUrl() != "")
71+
{
72+
const char *slash;
73+
74+
dstr_copy(&path, bs->GetUrl().c_str());
75+
dstr_replace(&path, "\\", "/");
76+
slash = strrchr(path.array, '/');
77+
if (slash)
78+
dstr_resize(&path, slash - path.array + 1);
79+
}
80+
81+
6782
obs_property_set_modified_callback(prop, is_local_file_modified);
6883
obs_properties_add_path(props, "local_file",
6984
obs_module_text("Local file"), OBS_PATH_FILE, "*.*",
70-
nullptr);
85+
path.array);
7186
obs_properties_add_text(props, "url",
7287
obs_module_text("URL"), OBS_TEXT_DEFAULT);
7388

0 commit comments

Comments
 (0)