當前位置: 首頁>>代碼示例>>C#>>正文


C# Unix.StdioFileStream類代碼示例

本文整理匯總了C#中Mono.Unix.StdioFileStream的典型用法代碼示例。如果您正苦於以下問題:C# StdioFileStream類的具體用法?C# StdioFileStream怎麽用?C# StdioFileStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StdioFileStream類屬於Mono.Unix命名空間,在下文中一共展示了StdioFileStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CtorFileNotFoundException1

		public void CtorFileNotFoundException1 ()
		{
			string path = TempFolder + DSC + "thisfileshouldnotexists.test";
			DeleteFile (path);
			StdioFileStream stream = null;
			try {                		
				stream = new StdioFileStream (path, FileMode.Open);
			} finally {
				if (stream != null)
					stream.Close ();
				DeleteFile (path);
			}
		}			
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:13,代碼來源:StdioFileStreamTest.cs

示例2: TestCtr

		public void TestCtr ()
		{
			string path = TempFolder + DSC + "testfilestream.tmp.1";
			DeleteFile (path);
			StdioFileStream stream = null;
			try {
				stream = new StdioFileStream (path, FileMode.Create);
			} finally {

				if (stream != null)
					stream.Close ();
				DeleteFile (path);                	
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:14,代碼來源:StdioFileStreamTest.cs

示例3: TestReadByteVerifyAccessMode

		public void TestReadByteVerifyAccessMode ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			StdioFileStream stream = null;

			try {
				stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
				int readByte = stream.ReadByte ();
			} finally {
				if (stream != null)
					stream.Close();
				DeleteFile (path);
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:16,代碼來源:StdioFileStreamTest.cs

示例4: ReadBytePastEndOfStream

		public void ReadBytePastEndOfStream () 
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);
			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Seek (0, SeekOrigin.End);
				Assert.AreEqual (-1, stream.ReadByte (), "ReadByte");
				stream.Close ();
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:10,代碼來源:StdioFileStreamTest.cs

示例5: CtorArgumentException3

		public void CtorArgumentException3 ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			StdioFileStream stream = null;

			DeleteFile (path);

			try {
				stream = new StdioFileStream (".test.test.test.2", FileMode.Truncate, FileAccess.Read);
			} finally {
				if (stream != null)
					stream.Close ();

				DeleteFile (path);
			}                	
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:16,代碼來源:StdioFileStreamTest.cs

示例6: Seek_InvalidSeekOrigin

		public void Seek_InvalidSeekOrigin () 
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Seek (0, (SeekOrigin) (-1));
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:9,代碼來源:StdioFileStreamTest.cs

示例7: Seek_Disposed

		public void Seek_Disposed () 
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);
			StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
			stream.Close ();
			stream.Seek (0, SeekOrigin.Begin);
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:8,代碼來源:StdioFileStreamTest.cs

示例8: Read_CountNegative

		public void Read_CountNegative ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Read (new byte[0], 1, -1);
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:9,代碼來源:StdioFileStreamTest.cs

示例9: CtorArgumentException1

		public void CtorArgumentException1 ()
		{
			StdioFileStream stream;
			stream = new StdioFileStream ("", FileMode.Create);
			stream.Close ();
		}			
開發者ID:sushihangover,項目名稱:playscript,代碼行數:6,代碼來源:StdioFileStreamTest.cs

示例10: TestDefaultProperties

		public void TestDefaultProperties ()
		{
#if XXX
			string path = TempFolder + Path.DirectorySeparatorChar + "testStdioFileStream.tmp.2";
			DeleteFile (path);

			StdioFileStream stream = new StdioFileStream (path, FileMode.Create);

			Assert.AreEqual (true, stream.CanRead, "test#01");
			Assert.AreEqual (true, stream.CanSeek, "test#02");
			Assert.AreEqual (true, stream.CanWrite, "test#03");
			Assert.AreEqual (0, stream.Position, "test#06");
			Assert.AreEqual ("Mono.Unix.StdioFileStream", stream.ToString(), "test#07");
			stream.Close ();
			DeleteFile (path);

			stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read);
			Assert.AreEqual (true, stream.CanRead, "test#08");
			Assert.AreEqual (true, stream.CanSeek, "test#09");
			Assert.AreEqual (false, stream.CanWrite, "test#10");
			Assert.AreEqual (0, stream.Position, "test#13");
			Assert.AreEqual ("Mono.Unix.StdioFileStream", stream.ToString(), "test#14");                	
			stream.Close ();

			stream = new StdioFileStream (path, FileMode.Truncate, FileAccess.Write);
			Assert.AreEqual (false, stream.CanRead, "test#15");
			Assert.AreEqual (true, stream.CanSeek, "test#16");
			Assert.AreEqual (true, stream.CanWrite, "test#17");
			Assert.AreEqual (0, stream.Position, "test#20");
			Assert.AreEqual ("Mono.Unix.StdioFileStream", stream.ToString(), "test#21");                	
			stream.Close ();
			DeleteFile (path);
#endif
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:34,代碼來源:StdioFileStreamTest.cs

示例11: PositionAfterWrite

		public void PositionAfterWrite ()
		{
#if XXX
			string path = TempFolder + DSC + "FST.Position.Test";
			DeleteFile (path);			

			StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, 
				FileAccess.ReadWrite);

			FilePosition fp;

			Assert.AreEqual (0, stream.Position, "test #01");
			Assert.AreEqual ("(Mono.Unix.FilePosition 00000000", 
				(fp = stream.FilePosition).ToString().Substring (0, 32), "test#02");
			fp.Dispose ();

			byte[] message = new byte[]{
				(byte) 'H', (byte) 'e', (byte) 'l', (byte) 'l', (byte) 'o', (byte) ' ',
				(byte) 'W', (byte) 'o', (byte) 'r', (byte) 'l', (byte) 'd',
			};

			stream.Write (message, 0, message.Length);

			Assert.AreEqual (11, stream.Position, "test #03");
			Assert.AreEqual (message.Length, stream.Position, "test #04");
			Assert.AreEqual ("(Mono.Unix.FilePosition 0B000000", 
				(fp = stream.FilePosition).ToString().Substring (0, 32), "test#04");
			fp.Dispose ();
#endif
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:30,代碼來源:StdioFileStreamTest.cs

示例12: Length

		public void Length ()
		{
			// Test that the Length property takes into account the data
			// in the buffer
			string path = TempFolder + DSC + "StdioFileStreamTest.Length";

			DeleteFile (path);

			StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew);

			byte[] outbytes = new byte [] {1, 2, 3, 4};

			stream.Write (outbytes, 0, 4);
			Assert.AreEqual (stream.Length, 4);
			stream.Close ();
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:16,代碼來源:StdioFileStreamTest.cs

示例13: Flush

		public void Flush ()
		{
#if XXX
		    // This test depends too much on the internal implementation of stdio's FILE
		    
			string path = TempFolder + DSC + "StdioFileStreamTest.Flush";
			StdioFileStream stream = null;
			StdioFileStream stream2 = null;

			DeleteFile (path);

			try {
				stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
				stream2 = new StdioFileStream (path, FileMode.Open, FileAccess.ReadWrite);

				stream.Write (new byte [] {1, 2, 3, 4, 5}, 0, 5);

				byte [] bytes = new byte [5];
				stream2.Read (bytes, 0, 5);

				Assert.AreEqual (0, bytes [0], "test#01");
				Assert.AreEqual (0, bytes [1], "test#02");
				Assert.AreEqual (0, bytes [2], "test#03");
				Assert.AreEqual (0, bytes [3], "test#04");

				stream.Flush ();
				stream2.Read (bytes, 0, 5);			
				Assert.AreEqual (1, bytes [0], "test#05");
				Assert.AreEqual (2, bytes [1], "test#06");
				Assert.AreEqual (3, bytes [2], "test#07");
				Assert.AreEqual (4, bytes [3], "test#08");
			} finally {
				if (stream != null)
					stream.Close ();
				if (stream2 != null)
					stream2.Close ();

				Console.WriteLine ("P: " + path);
				//DeleteFile (path);
			}
#endif
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:42,代碼來源:StdioFileStreamTest.cs

示例14: Write

		public void Write ()
		{
			string path = TempFolder + DSC + "StdioFileStreamTest.Write";

			DeleteFile (path);

			StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);

			byte[] outbytes = new byte [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
			byte[] bytes = new byte [15];

			// Check that the data is flushed when we overflow the buffer
			// with a large amount of data
			stream.Write (outbytes, 0, 5);
			stream.Write (outbytes, 5, 10);
			stream.Seek (0, SeekOrigin.Begin);

			stream.Read (bytes, 0, 15);
			for (int i = 0; i < 15; ++i)
				Assert.AreEqual (i + 1, bytes [i]);

			// Check that the data is flushed when we overflow the buffer
			// with a small amount of data
			stream.Write (outbytes, 0, 7);
			stream.Write (outbytes, 7, 7);
			stream.Write (outbytes, 14, 1);

			stream.Seek (15, SeekOrigin.Begin);
			Array.Clear (bytes, 0, bytes.Length);
			stream.Read (bytes, 0, 15);
			for (int i = 0; i < 15; ++i)
				Assert.AreEqual (i + 1, bytes [i]);
			stream.Close ();
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:34,代碼來源:StdioFileStreamTest.cs

示例15: CtorAccess1Read2Read

		public void CtorAccess1Read2Read ()
		{
			StdioFileStream fs = null;
			StdioFileStream fs2 = null;
			string tempPath = Path.Combine (TempFolder, "temp");
			try {
				if (!File.Exists (tempPath)) {
					TextWriter tw = File.CreateText (tempPath);
					tw.Write ("FOO");
					tw.Close ();
				}
				fs = new StdioFileStream (tempPath, FileMode.Open, FileAccess.Read);
				fs2 = new StdioFileStream (tempPath, FileMode.Open, FileAccess.Read);
			} finally {
				if (fs != null)
					fs.Close ();
				if (fs2 != null)
					fs2.Close ();
			}
		}
開發者ID:sushihangover,項目名稱:playscript,代碼行數:20,代碼來源:StdioFileStreamTest.cs


注:本文中的Mono.Unix.StdioFileStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。