• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Unix.StdioFileStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.Unix.StdioFileStream的典型用法代码示例。如果您正苦于以下问题:C# StdioFileStream类的具体用法?C# StdioFileStream怎么用?C# StdioFileStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StdioFileStream类属于Mono.Unix命名空间,在下文中一共展示了StdioFileStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: CtorIOException

		public void CtorIOException ()
		{			
			string path = TempFolder + DSC + "CTorIOException.Test";
			StdioFileStream stream = null;
			StdioFileStream stream2 = null;
			DeleteFile (path);

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

				// used by an another process
				stream2 = new StdioFileStream (path, FileMode.OpenOrCreate);
			} finally {
				if (stream != null)
					stream.Close ();
				if (stream2 != null)
					stream2.Close ();
				DeleteFile (path);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:20,代码来源:StdioFileStreamTest.cs


示例17: TestFlushNotOwningHandle

		public void TestFlushNotOwningHandle ()
		{
			string path = Path.Combine (TempFolder, "TestFlushNotOwningHandle");
			DeleteFile (path);

			StdioFileStream s = new StdioFileStream (path, FileMode.Create);
			using (StdioFileStream s2 = new StdioFileStream (s.Handle, FileAccess.Write, false)) {
				byte[] buf = new byte [2];
				buf [0] = (int)'1';
				s2.Write (buf, 0, 1);
			}

			s.Position = 0;
			Assert.AreEqual (s.ReadByte (), (int)'1');
			s.Close ();
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:16,代码来源:StdioFileStreamTest.cs


示例18: Seek

		public void Seek ()
		{
			string path = TempFolder + DSC + "FST.Seek.Test";
			DeleteFile (path);			

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

			stream.Write (new byte [] {1, 2, 3, 4, 5, 6, 7, 8, 10}, 0, 9);
			Assert.AreEqual (5, stream2.Seek (5, SeekOrigin.Begin), "test#01");
			Assert.AreEqual (-1, stream2.ReadByte (), "test#02");

			Assert.AreEqual (2, stream2.Seek (-3, SeekOrigin.Current), "test#03");
			Assert.AreEqual (-1, stream2.ReadByte (), "test#04");

			Assert.AreEqual (12, stream.Seek (3, SeekOrigin.Current), "test#05");
			Assert.AreEqual (-1, stream.ReadByte (), "test#06");

			Assert.AreEqual (5, stream.Seek (-7, SeekOrigin.Current), "test#07");
			Assert.AreEqual (6, stream.ReadByte (), "test#08");

			Assert.AreEqual (5, stream2.Seek (5, SeekOrigin.Begin), "test#09");
			Assert.AreEqual (6, stream2.ReadByte (), "test#10");

			stream.Close ();
			stream2.Close ();

			DeleteFile (path);
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:29,代码来源:StdioFileStreamTest.cs


示例19: Read_OffsetOverflow

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

			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Read (new byte[0], Int32.MaxValue, 1);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:9,代码来源:StdioFileStreamTest.cs


示例20: TestSeek

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

			StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
			stream.Write (new byte[] {1, 2, 3, 4, 5, 6, 7, 8 , 9, 10}, 0, 10);

			stream.Seek (5, SeekOrigin.End);
			Assert.AreEqual (-1, stream.ReadByte (), "test#01");

			stream.Seek (-5, SeekOrigin.End);
			Assert.AreEqual (6, stream.ReadByte (), "test#02");

			try {
				stream.Seek (-11, SeekOrigin.End);
				Assert.Fail ();
			} catch (Exception e) {
				Assert.AreEqual (typeof (IOException), e.GetType (), "test#03");
			}

			stream.Seek (19, SeekOrigin.Begin);
			Assert.AreEqual (-1, stream.ReadByte (), "test#04");

			stream.Seek (1, SeekOrigin.Begin);
			Assert.AreEqual (2, stream.ReadByte (), "test#05");

			stream.Seek (3, SeekOrigin.Current);
			Assert.AreEqual (6, stream.ReadByte (), "test#06");

			stream.Seek (-2, SeekOrigin.Current);
			Assert.AreEqual (5, stream.ReadByte (), "test#07");

			stream.Flush ();

			// Test that seeks work correctly when seeking inside the buffer
			stream.Seek (0, SeekOrigin.Begin);
			stream.WriteByte (0);
			stream.WriteByte (1);
			stream.Seek (0, SeekOrigin.Begin);
			byte[] buf = new byte [1];
			buf [0] = 2;
			stream.Write (buf, 0, 1);
			stream.Write (buf, 0, 1);
			stream.Flush ();
			stream.Seek (0, SeekOrigin.Begin);
			Assert.AreEqual (2, stream.ReadByte (), "test#08");
			Assert.AreEqual (2, stream.ReadByte (), "test#09");

			stream.Close ();

			DeleteFile (path);
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:53,代码来源:StdioFileStreamTest.cs



注:本文中的Mono.Unix.StdioFileStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Unix.UnixSignal类代码示例发布时间:2022-05-26
下一篇:
C# Highlighting.SyntaxMode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap