| 398 | |
| 399 | |
| 400 | void Manager::loadDialog() { |
| 401 | if (!promptClear(string::translate("patch.loadConfirm"))) |
| 402 | return; |
| 403 | |
| 404 | std::string dir; |
| 405 | if (this->path != "") { |
| 406 | dir = system::getDirectory(this->path); |
| 407 | } |
| 408 | |
| 409 | // Use fallback lastPatchDirectory |
| 410 | if (dir == "" || !system::isDirectory(dir)) { |
| 411 | dir = settings::lastPatchDirectory; |
| 412 | |
| 413 | // Use fallback <Rack user dir>/patches |
| 414 | if (dir == "" || !system::isDirectory(dir)) { |
| 415 | dir = asset::user("patches"); |
| 416 | system::createDirectory(dir); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); |
| 421 | DEFER({osdialog_filters_free(filters);}); |
| 422 | |
| 423 | char* pathC = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters); |
| 424 | if (!pathC) { |
| 425 | // Cancel silently |
| 426 | return; |
| 427 | } |
| 428 | std::string path = pathC; |
| 429 | std::free(pathC); |
| 430 | |
| 431 | loadAction(path); |
| 432 | } |
| 433 | |
| 434 | |
| 435 | void Manager::loadPathDialog(std::string path) { |
nothing calls this directly
no test coverage detected