UI: Rewrite profile system to enable user-provided storage location
This change enables loading profiles from locations different than OBS' own configuration directory. It also rewrites profile management in the app to work off an in-memory collection of profiles found on disk and does not require iterating over directory contents for most profile interactions by the app.
This commit is contained in:
parent
2635cf3a2a
commit
607d37b423
9 changed files with 1772 additions and 1601 deletions
|
|
@ -1616,19 +1616,28 @@ struct AdvancedOutput : BasicOutputHandler {
|
|||
|
||||
static OBSData GetDataFromJsonFile(const char *jsonFile)
|
||||
{
|
||||
char fullPath[512];
|
||||
const OBSBasic *basic =
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath =
|
||||
currentProfile.path / std::filesystem::u8path(jsonFile);
|
||||
|
||||
OBSDataAutoRelease data = nullptr;
|
||||
|
||||
int ret = GetProfilePath(fullPath, sizeof(fullPath), jsonFile);
|
||||
if (ret > 0) {
|
||||
BPtr<char> jsonData = os_quick_read_utf8_file(fullPath);
|
||||
if (!jsonFilePath.empty()) {
|
||||
BPtr<char> jsonData = os_quick_read_utf8_file(
|
||||
jsonFilePath.u8string().c_str());
|
||||
|
||||
if (!!jsonData) {
|
||||
data = obs_data_create_from_json(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
if (!data)
|
||||
if (!data) {
|
||||
data = obs_data_create();
|
||||
}
|
||||
|
||||
return data.Get();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue