From 844c185f87eae47a25ce86e2977d60bc9c57476d Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 23 Mar 2014 12:50:33 +0000 Subject: WinGui: Restore rolled back tabbing fix + added a check for illegal characters to the destination text box. Add to Queue will now prevent items from begin added with illegal characters also. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6129 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Helpers/FileHelper.cs | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Helpers/FileHelper.cs (limited to 'win/CS/HandBrakeWPF/Helpers/FileHelper.cs') diff --git a/win/CS/HandBrakeWPF/Helpers/FileHelper.cs b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs new file mode 100644 index 000000000..7a882de0b --- /dev/null +++ b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs @@ -0,0 +1,56 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Helper methods for dealing with files. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Helpers +{ + using System; + using System.IO; + + /// + /// Helper methods for dealing with files. + /// + public class FileHelper + { + /// + /// The file path has invalid chars. + /// + /// + /// The path. + /// + /// + /// The . + /// + public static bool FilePathHasInvalidChars(string path) + { + bool result = false; + if (!string.IsNullOrEmpty(path)) + { + try + { + string file = Path.GetFileNameWithoutExtension(path); + string directory = Path.GetDirectoryName(path); + + // TODO this may not be necessary. + if ((!string.IsNullOrEmpty(directory) && directory.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1) || + file.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidFileNameChars()) != -1) + { + return true; + } + + } + catch (ArgumentException) + { + result = true; + } + } + + return result; + } + } +} -- cgit v1.2.3