MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / uiFileBrowserSelected

Function uiFileBrowserSelected

src/CardinalUI.cpp:1196–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1194 }
1195
1196 void uiFileBrowserSelected(const char* const filename) override
1197 {
1198 if (filename == nullptr)
1199 return;
1200
1201 rack::contextSet(context);
1202 WindowParametersRestore(context->window);
1203
1204 std::string sfilename = filename;
1205
1206 if (saving)
1207 {
1208 const bool uncompressed = savingUncompressed;
1209 savingUncompressed = false;
1210
1211 if (rack::system::getExtension(sfilename) != ".vcv")
1212 sfilename += ".vcv";
1213
1214 try {
1215 if (uncompressed)
1216 {
1217 context->engine->prepareSave();
1218
1219 if (json_t* const rootJ = context->patch->toJson())
1220 {
1221 if (FILE* const file = std::fopen(sfilename.c_str(), "w"))
1222 {
1223 json_dumpf(rootJ, file, JSON_INDENT(2));
1224 std::fclose(file);
1225 }
1226 json_decref(rootJ);
1227 }
1228 }
1229 else
1230 {
1231 context->patch->save(sfilename);
1232 }
1233 }
1234 catch (rack::Exception& e) {
1235 std::string message = rack::string::f("Could not save patch: %s", e.what());
1236 asyncDialog::create(message.c_str());
1237 return;
1238 }
1239 }
1240 else
1241 {
1242 try {
1243 context->patch->load(sfilename);
1244 } catch (rack::Exception& e) {
1245 std::string message = rack::string::f("Could not load patch: %s", e.what());
1246 asyncDialog::create(message.c_str());
1247 return;
1248 }
1249 }
1250
1251 context->patch->path = sfilename;
1252 context->patch->pushRecentPath(sfilename);
1253 context->history->setSaved();

Callers

nothing calls this directly

Calls 10

fFunction · 0.85
createFunction · 0.85
prepareSaveMethod · 0.80
c_strMethod · 0.80
syncfsFunction · 0.70
contextSetFunction · 0.50
WindowParametersRestoreFunction · 0.50
toJsonMethod · 0.45
saveMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected