예제 #1
0
		private RAMDirectory(Directory dir, bool closeDir)
		{
			System.String[] files = dir.List();
			for (int i = 0; i < files.Length; i++)
			{
				// make place on ram disk
				OutputStream os = CreateFile(System.IO.Path.GetFileName(files[i]));
				// read current file
				InputStream is_Renamed = dir.OpenFile(files[i]);
				// and copy to ram disk
				int len = (int) is_Renamed.Length();
				byte[] buf = new byte[len];
				is_Renamed.ReadBytes(buf, 0, len);
				os.WriteBytes(buf, len);
				// graceful cleanup
				is_Renamed.Close();
				os.Close();
			}
			if (closeDir)
				dir.Close();
		}
예제 #2
0
		/// <summary> Creates a new <code>RAMDirectory</code> instance from a different
		/// <code>Directory</code> implementation.  This can be used to load
		/// a disk-based index into memory.
		/// <P>
		/// This should be used only with indices that can fit into memory.
		/// 
		/// </summary>
		/// <param name="dir">a <code>Directory</code> value
		/// </param>
		/// <exception cref=""> IOException if an error occurs
		/// </exception>
		public RAMDirectory(Directory dir) : this(dir, false)
		{
		}