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.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Gabriel Maia 2016-09-06 16:16:18 +00:00 committed by Adrien Destugues
parent 584fd9619c
commit c6b4e47a50
1 changed files with 16 additions and 0 deletions

View File

@ -619,6 +619,22 @@ ScreenshotWindow::_SaveScreenshot()
if (path == NULL)
return B_ERROR;
BEntry directoryEntry;
directoryEntry.SetTo(path.Path());
// create folder if it doesn't exist
// necessary, for example, when the user selects the Artwork folder from
// the list of predefined folders.
if (!directoryEntry.Exists()) {
if (create_directory(path.Path(), 0755) != B_OK) {
return B_ERROR;
}
} else if (!directoryEntry.IsDirectory()) {
// the entry exists but is not a directory.
// not much we can do
return B_ERROR;
}
path.Append(fNameControl->Text());
BEntry entry;