[Mono-bugs] [Bug 71371][Min] New - Locking on portions of file fails.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 18 Jan 2005 01:10:53 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=71371

--- shadow/71371	2005-01-18 01:10:53.000000000 -0500
+++ shadow/71371.tmp.9590	2005-01-18 01:10:53.000000000 -0500
@@ -0,0 +1,54 @@
+Bug#: 71371
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Locking on portions of file fails.
+
+.NET implements file-locking behavior. from our test suite:
+
+using System;
+using System.IO;
+class X {
+		static void Main ()
+		{
+			string path = "TestLock";
+                	File.Delete (path);
+
+                	FileStream stream = new FileStream (path,
+FileMode.CreateNew, FileAccess.ReadWrite);
+                	                	
+	               	stream.Write (new Byte [] {0,1,2,3,4,5,6,7,8,9,10}, 0,
+10);                              	
+                	stream.Close ();
+
+                	stream = new FileStream (path, FileMode.Open,
+FileAccess.ReadWrite);
+                	
+                	stream.Lock (0, 5);
+                	
+                	FileStream stream2 = new FileStream (path , FileMode.Open,
+FileAccess.Read, FileShare.ReadWrite);
+                	
+                	byte [] bytes = new byte [5];
+                	try {                		
+                		stream2.Read (bytes, 0, 5);
+				Console.WriteLine ("The read should have failed for the portion locked");
+                	} catch (Exception e) {
+				Console.WriteLine ("Ok");
+                	}
+		}
+}
+
+This program should print "ok"