Ticket #8519: commit-64eda3e.diff

File commit-64eda3e.diff, 1.9 KB (added by przemub, 11 years ago)

A patch from Przemysław Buczkowski (GCI 2012) (corrected) (corrected)

  • src/apps/expander/ExpanderWindow.cpp

    commit 64eda3eec23f8adb62d9cabe3ff0ad4fff050b74
    Author: Przemysław Buczkowski <przemub@yahoo.pl>
    Date:   Sun Dec 2 11:26:53 2012 +0100
    
        Expander: option to create directories that don't exist
        
        Closes bug #8519.
        
        Signed-off-by: Przemysław Buczkowski <przemub@yahoo.pl>
    
    diff --git a/src/apps/expander/ExpanderWindow.cpp b/src/apps/expander/ExpanderWindow.cpp
    index 9ea6fdc..139a4da 100644
    a b ExpanderWindow::ValidateDest()  
    150150    BVolume volume;
    151151    if (!entry.Exists()) {
    152152        BAlert* alert = new BAlert("destAlert",
    153             B_TRANSLATE("The destination folder does not exist."),
    154             B_TRANSLATE("Cancel"), NULL, NULL,
     153            B_TRANSLATE("Destination folder doesn't exist, create?"),
     154            B_TRANSLATE("Yes"), B_TRANSLATE("No"), NULL,
    155155            B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
    156         alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
    157         alert->Go();
    158         return false;
     156        alert->SetShortcut(0, B_ESCAPE);
     157        if (alert->Go() == 0) {
     158            if(create_directory(fDestText->Text(), 0755) == B_OK) {
     159                BEntry newEntry(fDestText->Text(), true);
     160                newEntry.GetRef(&fDestRef);
     161                return true;
     162            }
     163            else {
     164                BAlert* alert = new BAlert("stopAlert",
     165                    B_TRANSLATE("Failed to create the destination folder."),
     166                    B_TRANSLATE("Cancel"), NULL, NULL,
     167                    B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
     168                alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
     169                alert->Go();
     170                return false;
     171            }
     172        } else {
     173            BAlert* alert = new BAlert("stopAlert",
     174                B_TRANSLATE("The extraction operation aborted."),
     175                B_TRANSLATE("Cancel"), NULL, NULL,
     176                B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
     177            alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
     178            alert->Go();
     179            return false;
     180        }
    159181    } else if (!entry.IsDirectory()) {
    160182        BAlert* alert = new BAlert("destAlert",
    161183            B_TRANSLATE("The destination is not a folder."),