| 118 | } |
| 119 | |
| 120 | void DialogAutosave::Populate(std::map<wxString, AutosaveFile> &files_map, std::string const& path, wxString const& filter, wxString const& name_fmt) { |
| 121 | wxString directory(config::path->Decode(path).wstring()); |
| 122 | |
| 123 | wxDir dir; |
| 124 | if (!dir.Open(directory)) return; |
| 125 | |
| 126 | wxString fn; |
| 127 | if (!dir.GetFirst(&fn, "*" + filter, wxDIR_FILES)) |
| 128 | return; |
| 129 | |
| 130 | do { |
| 131 | wxDateTime date; |
| 132 | |
| 133 | wxString date_str; |
| 134 | wxString name = fn.Left(fn.size() - filter.size()).BeforeLast('.', &date_str); |
| 135 | if (!name) |
| 136 | name = date_str; |
| 137 | else { |
| 138 | if (!date.ParseFormat(date_str, "%Y-%m-%d-%H-%M-%S")) |
| 139 | name += "." + date_str; |
| 140 | } |
| 141 | if (!date.IsValid()) |
| 142 | date = wxFileName(directory, fn).GetModificationTime(); |
| 143 | |
| 144 | auto it = files_map.find(name); |
| 145 | if (it == files_map.end()) |
| 146 | it = files_map.insert({name, AutosaveFile{name}}).first; |
| 147 | it->second.versions.push_back(Version{wxFileName(directory, fn).GetFullPath(), date, agi::wxformat(name_fmt, date.Format())}); |
| 148 | } while (dir.GetNext(&fn)); |
| 149 | } |
| 150 | |
| 151 | void DialogAutosave::OnSelectFile(wxCommandEvent&) { |
| 152 | version_list->Clear(); |