コード例 #1
0
ファイル: TestCompoundFile.cs プロジェクト: yonder/mono
        private void  Demo_FSInputStreamBug(FSDirectory fsdir, System.String file)
        {
            // Setup the test file - we need more than 1024 bytes
            OutputStream os = fsdir.CreateFile(file);

            for (int i = 0; i < 2000; i++)
            {
                os.WriteByte((byte)i);
            }
            os.Close();

            InputStream in_Renamed = fsdir.OpenFile(file);

            // This read primes the buffer in InputStream
            byte b = in_Renamed.ReadByte();

            // Close the file
            in_Renamed.Close();

            // ERROR: this call should fail, but succeeds because the buffer
            // is still filled
            b = in_Renamed.ReadByte();

            // ERROR: this call should fail, but succeeds for some reason as well
            in_Renamed.Seek(1099);

            try
            {
                // OK: this call correctly fails. We are now past the 1024 internal
                // buffer, so an actual IO is attempted, which fails
                b = in_Renamed.ReadByte();
            }
            catch (System.IO.IOException e)
            {
            }
            catch (System.Exception)
            {
            }
        }
コード例 #2
0
ファイル: TestCompoundFile.cs プロジェクト: runefs/Marvin
		private void  Demo_FSInputStreamBug(FSDirectory fsdir, System.String file)
		{
			// Setup the test file - we need more than 1024 bytes
			OutputStream os = fsdir.CreateFile(file);
			for (int i = 0; i < 2000; i++)
			{
				os.WriteByte((byte) i);
			}
			os.Close();
			
			InputStream in_Renamed = fsdir.OpenFile(file);
			
			// This read primes the buffer in InputStream
			byte b = in_Renamed.ReadByte();
			
			// Close the file
			in_Renamed.Close();
			
			// ERROR: this call should fail, but succeeds because the buffer
			// is still filled
			b = in_Renamed.ReadByte();
			
			// ERROR: this call should fail, but succeeds for some reason as well
			in_Renamed.Seek(1099);
			
            try
            {
                // OK: this call correctly fails. We are now past the 1024 internal
                // buffer, so an actual IO is attempted, which fails
                b = in_Renamed.ReadByte();
            }
            catch (System.IO.IOException e)
            {
            }
            catch (System.Exception)
            {
            }
		}