Ticket #8519: gci2012-expander-patch-8519.diff

File gci2012-expander-patch-8519.diff, 2.1 KB (added by mr.Noisy, 11 years ago)

A patch from Przemysław Buczkowski (GCI 2012)

  • src/apps/expander/ExpanderWindow.cpp

    commit 7ff6b3846bd20a045a9025a88fe1a0864d187e2c
    Author: Przemysław Buczkowski <przemub@yahoo.pl>
    Date:   Sat Dec 1 21:56:06 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..3c480c9 100644
    a b  
    1313#include <Catalog.h>
    1414#include <CheckBox.h>
    1515#include <ControlLook.h>
     16#include <Directory.h>
    1617#include <Entry.h>
    1718#include <File.h>
    1819#include <GroupLayout.h>
    ExpanderWindow::ValidateDest()  
    150151    BVolume volume;
    151152    if (!entry.Exists()) {
    152153        BAlert* alert = new BAlert("destAlert",
    153             B_TRANSLATE("The destination folder does not exist."),
    154             B_TRANSLATE("Cancel"), NULL, NULL,
    155             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;
     154            B_TRANSLATE("Destination folder doesn't exist, create?"),
     155                B_TRANSLATE("Yes"), B_TRANSLATE("No"), NULL,
     156                B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
     157            alert->SetShortcut(0, B_ESCAPE);
     158            if (alert->Go() == 0) {
     159                if(create_directory(fDestText->Text(), 0755) == B_OK) {
     160                    entry.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."),