From 3af91d33254686e02b27ac804cdff0cc5eb595e3 Mon Sep 17 00:00:00 2001
From: Vivek Roy <vivekroy@outlook.com>
Date: Wed, 8 Mar 2017 02:12:36 +0000
Subject: [PATCH] Added error messages when converted file cannot be writen to
destination
---
src/apps/mediaconverter/MediaConverterApp.cpp | 25 ++++++++++++++++++++++++
src/apps/mediaconverter/MediaConverterWindow.cpp | 16 ++++++++++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/apps/mediaconverter/MediaConverterApp.cpp b/src/apps/mediaconverter/MediaConverterApp.cpp
index e3949d3..5fc41d0 100644
a
|
b
|
MediaConverterApp::_CreateOutputFile(BDirectory directory,
|
204 | 204 | |
205 | 205 | name.Append(outputFormat->file_extension); |
206 | 206 | |
| 207 | BEntry directoryEntry; |
| 208 | directory.GetEntry(&directoryEntry); |
| 209 | if (!directoryEntry.Exists()) { |
| 210 | BAlert* alert = new BAlert(B_TRANSLATE("Error"), |
| 211 | B_TRANSLATE("Selected directory not found. " |
| 212 | "Defaulting to /boot/home"), |
| 213 | B_TRANSLATE("OK")); |
| 214 | alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); |
| 215 | alert->Go(); |
| 216 | directory.SetTo("/boot/home"); |
| 217 | } |
| 218 | |
207 | 219 | BEntry inEntry(ref); |
208 | 220 | BEntry outEntry; |
209 | 221 | |
… |
… |
MediaConverterApp::_RunConvert()
|
318 | 330 | |
319 | 331 | |
320 | 332 | } else { |
| 333 | srcIndex++; |
| 334 | BString error( |
| 335 | B_TRANSLATE("Error converting '%filename'")); |
| 336 | error.ReplaceAll("%filename", inRef.name); |
| 337 | fWin->SetStatusMessage(error.String()); |
321 | 338 | fWin->Unlock(); |
322 | 339 | break; |
323 | 340 | } |
… |
… |
MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
|
391 | 408 | B_TRANSLATE("Audio quality not supported")); |
392 | 409 | fWin->Unlock(); |
393 | 410 | } |
| 411 | } else { |
| 412 | fWin->SetStatusMessage( |
| 413 | B_TRANSLATE("Error creating track.")); |
394 | 414 | } |
395 | 415 | |
396 | 416 | } else if (inFormat.IsVideo() && (videoCodec != NULL)) { |
… |
… |
MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
|
465 | 485 | fWin->SetVideoQualityLabel(videoQualitySupport); |
466 | 486 | fWin->Unlock(); |
467 | 487 | } |
| 488 | } else { |
| 489 | fWin->SetStatusMessage( |
| 490 | B_TRANSLATE("Error creating video.")); |
468 | 491 | } |
469 | 492 | } else { |
470 | 493 | // didn't do anything with the track |
| 494 | fWin->SetStatusMessage( |
| 495 | B_TRANSLATE("Input file not recognized as Audio or Video")); |
471 | 496 | inFile->ReleaseTrack(inTrack); |
472 | 497 | } |
473 | 498 | } |
diff --git a/src/apps/mediaconverter/MediaConverterWindow.cpp b/src/apps/mediaconverter/MediaConverterWindow.cpp
index 7fee41f..7cf8336 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 | } |