Ticket #10928: 0001-Screenshot-create-destination-folder-if-it-doesn-t-e.2.patch

File 0001-Screenshot-create-destination-folder-if-it-doesn-t-e.2.patch, 1.2 KB (added by gbl08ma, 8 years ago)
  • src/apps/screenshot/ScreenshotWindow.cpp

    From d7891cc0f190ad67240a9baf22b248e9de0819f8 Mon Sep 17 00:00:00 2001
    From: Gabriel Maia <gbl08ma@gmail.com>
    Date: Tue, 6 Sep 2016 16:16:18 +0000
    Subject: [PATCH] Screenshot: create destination folder if it doesn't exist
    
    This ensures the artwork folder is created if it doesn't exist,
    fixing the remainder of #10928.
    ---
     src/apps/screenshot/ScreenshotWindow.cpp | 16 ++++++++++++++++
     1 file changed, 16 insertions(+)
    
    diff --git a/src/apps/screenshot/ScreenshotWindow.cpp b/src/apps/screenshot/ScreenshotWindow.cpp
    index ec70bdf..58a6df3 100644
    a b ScreenshotWindow::_SaveScreenshot()  
    619619    if (path == NULL)
    620620        return B_ERROR;
    621621
     622    BEntry directoryEntry;
     623    directoryEntry.SetTo(path.Path());
     624
     625    // create folder if it doesn't exist
     626    // necessary, for example, when the user selects the Artwork folder from
     627    // the list of predefined folders.
     628    if (!directoryEntry.Exists()) {
     629        if (create_directory(path.Path(), 0755) != B_OK) {
     630            return B_ERROR;
     631        }
     632    } else if (!directoryEntry.IsDirectory()) {
     633        // the entry exists but is not a directory.
     634        // not much we can do
     635        return B_ERROR;
     636    }
     637
    622638    path.Append(fNameControl->Text());
    623639
    624640    BEntry entry;