From d886a5916dc8089e6d18f661e72a0dabf0f3fe5f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 20 Apr 2014 06:42:04 -0700 Subject: [PATCH] Create the output directory when collecting fonts to a zip --- src/dialog_fonts_collector.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dialog_fonts_collector.cpp b/src/dialog_fonts_collector.cpp index eb798951a..3b62b42f9 100644 --- a/src/dialog_fonts_collector.cpp +++ b/src/dialog_fonts_collector.cpp @@ -100,9 +100,20 @@ void FontsCollectorThread(AssFile *subs, agi::fs::path const& destination, FcMod std::unique_ptr out; std::unique_ptr zip; if (oper == CopyToZip) { + try { + agi::fs::CreateDirectory(destination.parent_path()); + } + catch (agi::fs::FileSystemError const& e) { + AppendText(wxString::Format(_("* Failed to create directory '%s': %s.\n"), + destination.parent_path().wstring(), to_wx(e.GetChainedMessage())), 2); + collector->AddPendingEvent(wxThreadEvent(EVT_COLLECTION_DONE)); + return; + } + out.reset(new wxFFileOutputStream(destination.wstring())); if (out->IsOk()) zip.reset(new wxZipOutputStream(*out)); + if (!out->IsOk() || !zip || !zip->IsOk()) { AppendText(wxString::Format(_("* Failed to open %s.\n"), destination.wstring()), 2); collector->AddPendingEvent(wxThreadEvent(EVT_COLLECTION_DONE));