CreateOutput() public method

Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
public CreateOutput ( System name ) : Lucene.Net.Store.IndexOutput
name System
return Lucene.Net.Store.IndexOutput
コード例 #1
0
ファイル: TestDirectory.cs プロジェクト: stgwilli/ravendb
        public virtual void  TestDetectClose()
        {
            Directory dir = new RAMDirectory();

            dir.Close();
            try
            {
                dir.CreateOutput("test");
                Assert.Fail("did not hit expected exception");
            }
            catch (AlreadyClosedException ace)
            {
            }

            dir = FSDirectory.Open(new System.IO.FileInfo(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())));
            dir.Close();
            try
            {
                dir.CreateOutput("test");
                Assert.Fail("did not hit expected exception");
            }
            catch (AlreadyClosedException ace)
            {
            }
        }
コード例 #2
0
		public virtual void  TestDetectClose()
		{
			Directory dir = new RAMDirectory();
			dir.Close();

            Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"), "did not hit expected exception");
			
			dir = FSDirectory.Open(new System.IO.DirectoryInfo(AppSettings.Get("tempDir", System.IO.Path.GetTempPath())));
			dir.Close();
			Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"), "did not hit expected exception");
		}
コード例 #3
0
        public virtual void  TestDetectClose()
        {
            Directory dir = new RAMDirectory();

            dir.Close();

            Assert.Throws <AlreadyClosedException>(() => dir.CreateOutput("test", null), "did not hit expected exception");

            dir = FSDirectory.Open(new System.IO.DirectoryInfo(AppSettings.Get("tempDir", System.IO.Path.GetTempPath())));
            dir.Close();
            Assert.Throws <AlreadyClosedException>(() => dir.CreateOutput("test", null), "did not hit expected exception");
        }
コード例 #4
0
 public override IndexOutput CreateOutput(string name, IOContext context)
 {
     if (VERBOSE)
     {
         Console.WriteLine("nrtdir.createOutput name=" + name);
     }
     if (DoCacheWrite(name, context))
     {
         if (VERBOSE)
         {
             Console.WriteLine("  to cache");
         }
         try
         {
             @delegate.DeleteFile(name);
         }
         catch (Exception ioe) when(ioe.IsIOException())
         {
             // this is fine: file may not exist
         }
         return(cache.CreateOutput(name, context));
     }
     else
     {
         try
         {
             cache.DeleteFile(name);
         }
         catch (Exception ioe) when(ioe.IsIOException())
         {
             // this is fine: file may not exist
         }
         return(@delegate.CreateOutput(name, context));
     }
 }
コード例 #5
0
 public override IndexOutput CreateOutput(string name, IOContext context)
 {
     if (VERBOSE)
     {
         Console.WriteLine("nrtdir.createOutput name=" + name);
     }
     if (DoCacheWrite(name, context))
     {
         if (VERBOSE)
         {
             Console.WriteLine("  to cache");
         }
         try
         {
             @delegate.DeleteFile(name);
         }
         catch (IOException) // LUCENENET: IDE0059: Remove unnecessary value assignment
         {
             // this is fine: file may not exist
         }
         return(cache.CreateOutput(name, context));
     }
     else
     {
         try
         {
             cache.DeleteFile(name);
         }
         catch (IOException) // LUCENENET: IDE0059: Remove unnecessary value assignment
         {
             // this is fine: file may not exist
         }
         return(@delegate.CreateOutput(name, context));
     }
 }
コード例 #6
0
ファイル: TestRAMDirectory.cs プロジェクト: stgwilli/ravendb
        public virtual void  TestIllegalEOF()
        {
            RAMDirectory dir = new RAMDirectory();
            IndexOutput  o   = dir.CreateOutput("out");

            byte[] b = new byte[1024];
            o.WriteBytes(b, 0, 1024);
            o.Close();
            IndexInput i = dir.OpenInput("out");

            i.Seek(1024);
            i.Close();
            dir.Close();
        }
コード例 #7
0
ファイル: TestRAMDirectory.cs プロジェクト: segovia/lucenenet
        public virtual void TestIllegalEOF()
        {
            RAMDirectory dir = new RAMDirectory();
            IndexOutput  o   = dir.CreateOutput("out", NewIOContext(Random));
            var          b   = new byte[1024];

            o.WriteBytes(b, 0, 1024);
            o.Dispose();
            IndexInput i = dir.OpenInput("out", NewIOContext(Random));

            i.Seek(1024);
            i.Dispose();
            dir.Dispose();
        }
コード例 #8
0
		public virtual void  TestDetectClose()
		{
			Directory dir = new RAMDirectory();
			dir.Close();
			try
			{
				dir.CreateOutput("test");
				Assert.Fail("did not hit expected exception");
			}
			catch (AlreadyClosedException ace)
			{
			}
			
			dir = FSDirectory.Open(new System.IO.FileInfo(Support.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())));
			dir.Close();
			try
			{
				dir.CreateOutput("test");
				Assert.Fail("did not hit expected exception");
			}
			catch (AlreadyClosedException ace)
			{
			}
		}
コード例 #9
0
ファイル: TestRAMDirectory.cs プロジェクト: segovia/lucenenet
        public virtual void TestSeekToEOFThenBack()
        {
            RAMDirectory dir = new RAMDirectory();

            IndexOutput o     = dir.CreateOutput("out", NewIOContext(Random));
            var         bytes = new byte[3 * RAMInputStream.BUFFER_SIZE];

            o.WriteBytes(bytes, 0, bytes.Length);
            o.Dispose();

            IndexInput i = dir.OpenInput("out", NewIOContext(Random));

            i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1);
            i.Seek(3 * RAMInputStream.BUFFER_SIZE);
            i.Seek(RAMInputStream.BUFFER_SIZE);
            i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE);
            i.Dispose();
            dir.Dispose();
        }
コード例 #10
0
        public override IndexOutput CreateOutput(string name, IOContext context)
        {
            if (VERBOSE)
            {
                Console.WriteLine("nrtdir.createOutput name=" + name);
            }
            if (DoCacheWrite(name, context))
            {
                if (VERBOSE)
                {
                    Console.WriteLine("  to cache");
                }
                try
                {
                    @delegate.DeleteFile(name);
                }
#pragma warning disable 168
                catch (IOException ioe)
#pragma warning restore 168
                {
                    // this is fine: file may not exist
                }
                return(cache.CreateOutput(name, context));
            }
            else
            {
                try
                {
                    cache.DeleteFile(name);
                }
#pragma warning disable 168
                catch (IOException ioe)
#pragma warning restore 168
                {
                    // this is fine: file may not exist
                }
                return(@delegate.CreateOutput(name, context));
            }
        }
コード例 #11
0
		public virtual void  TestIllegalEOF()
		{
			RAMDirectory dir = new RAMDirectory();
			IndexOutput o = dir.CreateOutput("out");
			byte[] b = new byte[1024];
			o.WriteBytes(b, 0, 1024);
			o.Close();
			IndexInput i = dir.OpenInput("out");
			i.Seek(1024);
			i.Close();
			dir.Close();
		}
コード例 #12
0
        public virtual void TestSeekToEOFThenBack()
        {
            RAMDirectory dir = new RAMDirectory();

            IndexOutput o = dir.CreateOutput("out", NewIOContext(Random()));
            var bytes = new byte[3 * RAMInputStream.BUFFER_SIZE];
            o.WriteBytes(bytes, 0, bytes.Length);
            o.Dispose();

            IndexInput i = dir.OpenInput("out", NewIOContext(Random()));
            i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1);
            i.Seek(3 * RAMInputStream.BUFFER_SIZE);
            i.Seek(RAMInputStream.BUFFER_SIZE);
            i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE);
            i.Dispose();
            dir.Dispose();
        }
コード例 #13
0
 public virtual void TestIllegalEOF()
 {
     RAMDirectory dir = new RAMDirectory();
     IndexOutput o = dir.CreateOutput("out", NewIOContext(Random()));
     var b = new byte[1024];
     o.WriteBytes(b, 0, 1024);
     o.Dispose();
     IndexInput i = dir.OpenInput("out", NewIOContext(Random()));
     i.Seek(1024);
     i.Dispose();
     dir.Dispose();
 }