summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.Designer.cs9
-rw-r--r--win/CS/HandBrakeWPF/Properties/Resources.resx3
-rw-r--r--win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs19
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs7
4 files changed, 38 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
index 2f8cd2bef..297a5caf1 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
@@ -729,6 +729,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to You do not have the appropriate folder permissions to write files into the directory you have chosen..
+ /// </summary>
+ public static string Main_NoPermissionsOnDirectory {
+ get {
+ return ResourceManager.GetString("Main_NoPermissionsOnDirectory", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to No Preset selected..
/// </summary>
public static string Main_NoPresetSelected {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx
index dcb268430..17767838a 100644
--- a/win/CS/HandBrakeWPF/Properties/Resources.resx
+++ b/win/CS/HandBrakeWPF/Properties/Resources.resx
@@ -808,4 +808,7 @@ Your preset file will be archived and new one created. You will need to re-creat
<data name="UserSettings_UnableToLoadSolution" xml:space="preserve">
<value>Your user settings file appears to be inaccessible or corrupted. You may have to delete the file and let HandBrake generate a new one.</value>
</data>
+ <data name="Main_NoPermissionsOnDirectory" xml:space="preserve">
+ <value>You do not have the appropriate folder permissions to write files into the directory you have chosen.</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
index 23b10ede8..5461605d0 100644
--- a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
+++ b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs
@@ -37,5 +37,24 @@ namespace HandBrakeWPF.Utilities
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HandBrake");
}
}
+
+
+ /// <summary>
+ /// Simple way of checking if a directory is writeable.
+ /// </summary>
+ /// <param name="dirPath">Path to check</param>
+ /// <returns>True if writable</returns>
+ public static bool IsWritable(string dirPath)
+ {
+ try
+ {
+ using (File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose)) { }
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 39f199892..fff4d8a70 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1378,6 +1378,13 @@ namespace HandBrakeWPF.ViewModels
return false;
}
+ if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination)))
+ {
+ this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOnDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ return false;
+ }
+
+
// Sanity check the filename
if (!string.IsNullOrEmpty(this.Destination) && FileHelper.FilePathHasInvalidChars(this.Destination))
{