From cb65bb873256e08920206840d8b91b51e6ca073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Buczkowski?= Date: Sun, 2 Dec 2012 13:43:00 +0100 Subject: [PATCH] Create dest. folder if it haven't existed. Fixes #8519 That was implemented during completing GCI 2012 task. Signed-off-by: Siarzhuk Zharski --- src/apps/expander/ExpanderWindow.cpp | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/apps/expander/ExpanderWindow.cpp b/src/apps/expander/ExpanderWindow.cpp index 9ea6fdc8ae..d667d5701d 100644 --- a/src/apps/expander/ExpanderWindow.cpp +++ b/src/apps/expander/ExpanderWindow.cpp @@ -150,19 +150,40 @@ ExpanderWindow::ValidateDest() BVolume volume; if (!entry.Exists()) { BAlert* alert = new BAlert("destAlert", - B_TRANSLATE("The destination folder does not exist."), - B_TRANSLATE("Cancel"), NULL, NULL, + B_TRANSLATE("Destination folder doesn't exist, create?"), + B_TRANSLATE("Yes"), B_TRANSLATE("No"), NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); - alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); - alert->Go(); - return false; + alert->SetShortcut(0, B_ESCAPE); + if (alert->Go() == 0) { + if (create_directory(fDestText->Text(), 0755) == B_OK) { + BEntry newEntry(fDestText->Text(), true); + newEntry.GetRef(&fDestRef); + return true; + } else { + BAlert* alert = new BAlert("stopAlert", + B_TRANSLATE("Failed to create the destination folder."), + B_TRANSLATE("Cancel"), NULL, NULL, + B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); + alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); + alert->Go(); + return false; + } + } else { + BAlert* alert = new BAlert("stopAlert", + B_TRANSLATE("The extraction operation aborted."), + B_TRANSLATE("Cancel"), NULL, NULL, + B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); + alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); + alert->Go(); + return false; + } } else if (!entry.IsDirectory()) { BAlert* alert = new BAlert("destAlert", B_TRANSLATE("The destination is not a folder."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); - alert->Go(); + alert->Go(); return false; } else if (entry.GetVolume(&volume) != B_OK || volume.IsReadOnly()) { BAlert* alert = new BAlert("destAlert",