Plan save-version targets in app core
This commit is contained in:
@@ -292,30 +292,19 @@ void App::dialog_save_ver()
|
||||
return;
|
||||
}
|
||||
|
||||
int current = 0;
|
||||
std::string next = doc_name + ".01";
|
||||
std::string base = doc_name;
|
||||
|
||||
std::regex r(R"((.*)\.(\w{2})$)");
|
||||
std::smatch m;
|
||||
if (std::regex_search(doc_name, m, r))
|
||||
{
|
||||
base = m[1].str();
|
||||
current = atoi(m[2].str().c_str());
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
doc_dir,
|
||||
doc_name,
|
||||
[](const std::string& path) {
|
||||
return Asset::exist(path);
|
||||
});
|
||||
if (!target) {
|
||||
message_box("Saving Error", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = current + 1; i < 99; i++)
|
||||
{
|
||||
static char tmp_name[256];
|
||||
sprintf(tmp_name, "%s.%02d", base.c_str(), i);
|
||||
next = tmp_name;
|
||||
if (Asset::exist(doc_dir + "/" + next + ".ppi"))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
doc_name = next;
|
||||
doc_path = doc_dir + "/" + next + ".ppi";
|
||||
doc_name = target.value().name;
|
||||
doc_path = target.value().path;
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
canvas->m_canvas->project_save(doc_path);
|
||||
|
||||
Reference in New Issue
Block a user