From a80eb2b4479f8b793a55882acab7e98f236f2410 Mon Sep 17 00:00:00 2001
From: Vivek Roy <vivekroyandroid@gmail.com>
Date: Sun, 5 Mar 2017 21:15:55 +0530
Subject: [PATCH] Added check of write-access of selected output folder
---
src/apps/mediaconverter/MediaConverterWindow.cpp | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/apps/mediaconverter/MediaConverterWindow.cpp b/src/apps/mediaconverter/MediaConverterWindow.cpp
index 7fee41f..bb2ead7 100644
a
|
b
|
|
9 | 9 | |
10 | 10 | #include <stdio.h> |
11 | 11 | #include <string.h> |
| 12 | #include <unistd.h> |
12 | 13 | |
13 | 14 | #include <Alert.h> |
14 | 15 | #include <Application.h> |
… |
… |
MediaConverterWindow::_CreateMenu()
|
1005 | 1006 | void |
1006 | 1007 | MediaConverterWindow::_SetOutputFolder(BEntry entry) |
1007 | 1008 | { |
1008 | | fOutputDir.SetTo(&entry); |
| 1009 | BPath path; |
| 1010 | entry.GetPath(&path); |
| 1011 | if (access(path.Path(), W_OK) != -1) { |
| 1012 | fOutputDir.SetTo(&entry); |
| 1013 | } else { |
| 1014 | BString errorString(B_TRANSLATE("Error writing to location: %strPath%." |
| 1015 | " Defaulting to location: /boot/home")); |
| 1016 | errorString.ReplaceFirst("%strPath%", path.Path()); |
| 1017 | BAlert* alert = new BAlert(B_TRANSLATE("Error"), |
| 1018 | errorString.String(), B_TRANSLATE("OK")); |
| 1019 | alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); |
| 1020 | alert->Go(); |
| 1021 | fOutputDir.SetTo("/boot/home") |
| 1022 | } |
1009 | 1023 | TruncateOutputFolderPath(); |
1010 | 1024 | } |