コード例 #1
0
ファイル: dialog_attachments.cpp プロジェクト: sthenc/Aegisub
void DialogAttachments::AttachFile(wxFileDialog &diag, AssEntryGroup group, wxString const& commit_msg) {
	if (diag.ShowModal() == wxID_CANCEL) return;

	wxArrayString filenames;
	diag.GetFilenames(filenames);

	wxArrayString paths;
	diag.GetPaths(paths);

	// Create attachments
	for (size_t i = 0; i < filenames.size(); ++i) {
		AssAttachment *newAttach = new AssAttachment(filenames[i], group);
		try {
			newAttach->Import(paths[i]);
		}
		catch (...) {
			delete newAttach;
			return;
		}
		ass->InsertLine(newAttach);
	}

	ass->Commit(commit_msg, AssFile::COMMIT_ATTACHMENT);

	UpdateList();
}