MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / Populate

Method Populate

src/dialog_autosave.cpp:120–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void 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
151void DialogAutosave::OnSelectFile(wxCommandEvent&) {
152 version_list->Clear();

Callers

nothing calls this directly

Calls 7

wxformatFunction · 0.85
DecodeMethod · 0.80
IsValidMethod · 0.80
push_backMethod · 0.80
OpenMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected