[banshee] IO: protect Directory class against NREs via ArgumentNullExceptions
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] IO: protect Directory class against NREs via ArgumentNullExceptions
- Date: Tue, 18 Feb 2014 17:58:48 +0000 (UTC)
commit e5f44acb2cbbff6d7427c6aac290f49b00bb7008
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Tue Feb 18 18:52:34 2014 +0100
IO: protect Directory class against NREs via ArgumentNullExceptions
src/Core/Banshee.Core/Banshee.IO/Directory.cs | 31 +++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.IO/Directory.cs b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
index 927ef88..0df03fc 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Directory.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
@@ -37,36 +37,67 @@ namespace Banshee.IO
{
public static bool Exists (string directory)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
return Provider.Directory.Exists (Provider.GetPath (directory));
}
public static void Create (string directory)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
Provider.Directory.Create (Provider.GetPath (directory));
}
public static void Move (SafeUri from, SafeUri to)
{
+ if (from == null) {
+ throw new ArgumentNullException ("from");
+ }
+ if (to == null) {
+ throw new ArgumentNullException ("to");
+ }
+
Provider.Directory.Move (from, to);
}
public static void Delete (string directory)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
Provider.Directory.Delete (Provider.GetPath (directory));
}
public static void Delete (string directory, bool recursive)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
Provider.Directory.Delete (Provider.GetPath (directory), recursive);
}
public static IEnumerable<SafeUri> GetFiles (string directory)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
return Provider.Directory.GetFiles (Provider.GetPath (directory));
}
public static IEnumerable<SafeUri> GetDirectories (string directory)
{
+ if (String.IsNullOrEmpty (directory)) {
+ throw new ArgumentNullException ("directory");
+ }
+
return Provider.Directory.GetDirectories (Provider.GetPath (directory));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]