Do not write our own filter code
The Win32 API has done everything for us, there is no need to do this oursevles.
This commit is contained in:
Родитель
96c8bd677b
Коммит
2b6ac966c0
|
@ -262,30 +262,7 @@ bool ShowSaveDialog(atom::NativeWindow* parent_window,
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string file_name = base::WideToUTF8(std::wstring(buffer));
|
*path = base::FilePath(buffer);
|
||||||
|
|
||||||
// Append extension according to selected filter.
|
|
||||||
if (!filters.empty()) {
|
|
||||||
UINT filter_index = 1;
|
|
||||||
save_dialog.GetPtr()->GetFileTypeIndex(&filter_index);
|
|
||||||
const Filter& filter = filters[filter_index - 1];
|
|
||||||
|
|
||||||
bool matched = false;
|
|
||||||
for (size_t i = 0; i < filter.second.size(); ++i) {
|
|
||||||
if (filter.second[i] == "*" ||
|
|
||||||
base::EndsWith(
|
|
||||||
file_name, filter.second[i],
|
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
|
||||||
matched = true;
|
|
||||||
break;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matched && !filter.second.empty())
|
|
||||||
file_name += ("." + filter.second[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
*path = base::FilePath(base::UTF8ToUTF16(file_name));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче