Procházet zdrojové kódy

2010-05-31 Carlos Alberto Cortez <[email protected]>

	* IsolatedStorage.cs:
	* IsolatedStorageFile.cs: Implement AvailableFreeSpace, Quota,
	UsedSize and IncreaseQuotaTo.


svn path=/trunk/mcs/; revision=158223
Carlos Alberto Cortez před 15 roky
rodič
revize
9238181d94

+ 6 - 0
mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog

@@ -1,3 +1,9 @@
+2010-05-31  Carlos Alberto Cortez <[email protected]>
+
+	* IsolatedStorage.cs:
+	* IsolatedStorageFile.cs: Implement AvailableFreeSpace, Quota,
+	UsedSize and IncreaseQuotaTo.
+
 2010-05-27  Carlos Alberto Cortez <[email protected]> 
 
 	* IsolatedStorageFile.cs: Implement CopyFile.

+ 31 - 0
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs

@@ -119,6 +119,29 @@ namespace System.IO.IsolatedStorage {
 			get { return storage_scope; }
 		}
 
+#if NET_4_0
+		[ComVisible (false)]
+		public virtual long AvailableFreeSpace {
+			get {
+				throw new InvalidOperationException ("This property is not defined for this store.");
+			}
+		}
+
+		[ComVisible (false)]
+		public virtual long Quota {
+			get {
+				throw new InvalidOperationException ("This property is not defined for this store.");
+			}
+		}
+
+		[ComVisible (false)]
+		public virtual long UsedSize {
+			get {
+				throw new InvalidOperationException ("This property is not defined for this store.");
+			}
+		}
+#endif
+
 		protected virtual char SeparatorExternal {
 			get { return System.IO.Path.DirectorySeparatorChar; }
 		}
@@ -157,6 +180,14 @@ namespace System.IO.IsolatedStorage {
 			storage_scope = scope;
 		}
 		public abstract void Remove ();
+
+#if NET_4_0
+		[ComVisible (false)]
+		public virtual bool IncreaseQuotaTo (long newQuotaSize)
+		{
+			return false;
+		}
+#endif
 	}
 }
 /* MOONLIGHT */

+ 43 - 0
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs

@@ -455,6 +455,37 @@ namespace System.IO.IsolatedStorage {
 		}
 
 #if NET_4_0
+		[ComVisible (false)]
+		public override long AvailableFreeSpace {
+			get {
+				CheckOpen ();
+
+				// See the notes for 'Quota'
+				return Int64.MaxValue;
+
+			}
+		}
+
+		[ComVisible (false)]
+		public override long Quota {
+			get {
+				CheckOpen ();
+
+				// Since we don't fully support CAS, we are likely
+				// going to return Int64.MaxValue always, but we return
+				// MaximumSize just in case.
+				return (long)MaximumSize;
+			}
+		}
+
+		[ComVisible (false)]
+		public override long UsedSize {
+			get {
+				CheckOpen ();
+				return (long)GetDirectorySize (directory);
+			}
+		}
+
 		[ComVisible (false)]
 		public static bool IsEnabled {
 			get {
@@ -729,6 +760,18 @@ namespace System.IO.IsolatedStorage {
 			return GetFileNames ("*");
 		}
 
+		[ComVisible (false)]
+		public override bool IncreaseQuotaTo (long newQuotaSize)
+		{
+			if (newQuotaSize < Quota)
+				throw new ArgumentException ();
+
+			CheckOpen ();
+
+			// .Net is supposed to be returning false, as mentioned in the docs.
+			return false;
+		}
+
 		[ComVisible (false)]
 		public void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName)
 		{