lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r835980 - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/Store/ Test/Store/
Date Fri, 13 Nov 2009 20:26:06 GMT
Author: aroush
Date: Fri Nov 13 20:26:04 2009
New Revision: 835980

URL: http://svn.apache.org/viewvc?rev=835980&view=rev
Log:
Fixed FSDirectory; we now use DirectoryInfo vs. FileInfo

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSDirectory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSLockFactory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/LockStressTest.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/MMapDirectory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NIOFSDirectory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NativeFSLockFactory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSDirectory.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSLockFactory.cs
    incubator/lucene.net/trunk/C#/src/Test/Store/TestDirectory.cs
    incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/FSDirectory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSDirectory.cs Fri Nov 13 20:26:04
2009
@@ -191,7 +191,7 @@
 		/// </returns>
 		public static FSDirectory GetDirectory(System.String path)
 		{
-			return GetDirectory(new System.IO.FileInfo(path), null);
+			return GetDirectory(new System.IO.DirectoryInfo(path), null);
 		}
 		
 		/// <summary>Returns the directory instance for the named location.
@@ -209,7 +209,7 @@
 		/// </returns>
 		public static FSDirectory GetDirectory(System.String path, LockFactory lockFactory)
 		{
-			return GetDirectory(new System.IO.FileInfo(path), lockFactory);
+			return GetDirectory(new System.IO.DirectoryInfo(path), lockFactory);
 		}
 		
 		/// <summary>Returns the directory instance for the named location.
@@ -222,10 +222,26 @@
 		/// </param>
 		/// <returns> the FSDirectory for the named file.  
 		/// </returns>
-		public static FSDirectory GetDirectory(System.IO.FileInfo file)
+		public static FSDirectory GetDirectory(System.IO.DirectoryInfo file)
 		{
 			return GetDirectory(file, null);
 		}
+
+        /// <summary>Returns the directory instance for the named location.
+        /// 
+        /// </summary>
+        /// <deprecated> Use {@link #Open(File)}
+        /// 
+        /// </deprecated>
+        /// <param name="file">the path to the directory.
+        /// </param>
+        /// <returns> the FSDirectory for the named file.  
+        /// </returns>
+        [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+        public static FSDirectory GetDirectory(System.IO.FileInfo file)
+        {
+            return GetDirectory(new System.IO.DirectoryInfo(file.FullName), null);
+        }
 		
 		/// <summary>Returns the directory instance for the named location.
 		/// 
@@ -240,44 +256,61 @@
 		/// </param>
 		/// <returns> the FSDirectory for the named file.  
 		/// </returns>
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
 		public static FSDirectory GetDirectory(System.IO.FileInfo file, LockFactory lockFactory)
 		{
-			file = GetCanonicalPath(file);
-			
-			FSDirectory dir;
-			lock (DIRECTORIES.SyncRoot)
-			{
-				dir = (FSDirectory) DIRECTORIES[file];
-				if (dir == null)
-				{
-					try
-					{
-						dir = (FSDirectory) System.Activator.CreateInstance(IMPL, true);
-					}
-					catch (System.Exception e)
-					{
-						throw new System.SystemException("cannot load FSDirectory class: " + e.ToString(),
e);
-					}
-					dir.Init(file, lockFactory);
-					DIRECTORIES[file] = dir;
-				}
-				else
-				{
-					// Catch the case where a Directory is pulled from the cache, but has a
-					// different LockFactory instance.
-					if (lockFactory != null && lockFactory != dir.GetLockFactory())
-					{
-						throw new System.IO.IOException("Directory was previously created with a different
LockFactory instance; please pass null as the lockFactory instance and use setLockFactory
to change it");
-					}
-					dir.checked_Renamed = false;
-				}
-			}
-			lock (dir)
-			{
-				dir.refCount++;
-			}
-			return dir;
+            return GetDirectory(new System.IO.DirectoryInfo(file.FullName), lockFactory);
 		}
+
+        /// <summary>Returns the directory instance for the named location.
+        /// 
+        /// </summary>
+        /// <deprecated> Use {@link #Open(File, LockFactory)}
+        /// 
+        /// </deprecated>
+        /// <param name="file">the path to the directory.
+        /// </param>
+        /// <param name="lockFactory">instance of {@link LockFactory} providing the
+        /// locking implementation.
+        /// </param>
+        /// <returns> the FSDirectory for the named file.  
+        /// </returns>
+        public static FSDirectory GetDirectory(System.IO.DirectoryInfo file, LockFactory
lockFactory)
+        {
+            FSDirectory dir;
+            lock (DIRECTORIES.SyncRoot)
+            {
+                dir = (FSDirectory)DIRECTORIES[file];
+                if (dir == null)
+                {
+                    try
+                    {
+                        dir = (FSDirectory)System.Activator.CreateInstance(IMPL);
+                    }
+                    catch (System.Exception e)
+                    {
+                        throw new System.SystemException("cannot load FSDirectory class:
" + e.ToString(), e);
+                    }
+                    dir.Init(file, lockFactory);
+                    DIRECTORIES[file] = dir;
+                }
+                else
+                {
+                    // Catch the case where a Directory is pulled from the cache, but has
a
+                    // different LockFactory instance.
+                    if (lockFactory != null && lockFactory != dir.GetLockFactory())
+                    {
+                        throw new System.IO.IOException("Directory was previously created
with a different LockFactory instance; please pass null as the lockFactory instance and use
setLockFactory to change it");
+                    }
+                    dir.checked_Renamed = false;
+                }
+            }
+            lock (dir)
+            {
+                dir.refCount++;
+            }
+            return dir;
+        }
 		
 		
 		/// <summary>Returns the directory instance for the named location.
@@ -295,7 +328,7 @@
 		/// </returns>
 		public static FSDirectory GetDirectory(System.String path, bool create)
 		{
-			return GetDirectory(new System.IO.FileInfo(path), create);
+			return GetDirectory(new System.IO.DirectoryInfo(path), create);
 		}
 		
 		/// <summary>Returns the directory instance for the named location.
@@ -311,61 +344,63 @@
 		/// </param>
 		/// <returns> the FSDirectory for the named file.  
 		/// </returns>
+		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the
3.0 release")]
 		public static FSDirectory GetDirectory(System.IO.FileInfo file, bool create)
 		{
-			FSDirectory dir = GetDirectory(file, null);
-			
-			// This is now deprecated (creation should only be done
-			// by IndexWriter):
-			if (create)
-			{
-				dir.Create();
-			}
-			
-			return dir;
+			return GetDirectory(new System.IO.DirectoryInfo(file.FullName), create);
 		}
+
+        /// <summary>Returns the directory instance for the named location.
+        /// 
+        /// </summary>
+        /// <deprecated> Use IndexWriter's create flag, instead, to
+        /// create a new index.
+        /// 
+        /// </deprecated>
+        /// <param name="file">the path to the directory.
+        /// </param>
+        /// <param name="create">if true, create, or erase any existing contents.
+        /// </param>
+        /// <returns> the FSDirectory for the named file.  
+        /// </returns>
+        public static FSDirectory GetDirectory(System.IO.DirectoryInfo file, bool create)
+        {
+            FSDirectory dir = GetDirectory(file, null);
+
+            // This is now deprecated (creation should only be done
+            // by IndexWriter):
+            if (create)
+            {
+                dir.Create();
+            }
+
+            return dir;
+        }
 		
 		/// <deprecated> 
 		/// </deprecated>
 		private void  Create()
 		{
-			bool tmpBool;
-			if (System.IO.File.Exists(directory.FullName))
-				tmpBool = true;
-			else
-				tmpBool = System.IO.Directory.Exists(directory.FullName);
-			if (tmpBool)
-			{
-				System.String[] files = SupportClass.FileSupport.GetLuceneIndexFiles(directory.FullName,
IndexFileNameFilter.GetFilter()); // clear old files
-				if (files == null)
-					throw new System.IO.IOException("cannot read directory " + directory.FullName + ": list()
returned null");
-				for (int i = 0; i < files.Length; i++)
-				{
-					System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName,
files[i]));
-					bool tmpBool2;
-					if (System.IO.File.Exists(file.FullName))
-					{
-						System.IO.File.Delete(file.FullName);
-						tmpBool2 = true;
-					}
-					else if (System.IO.Directory.Exists(file.FullName))
-					{
-						System.IO.Directory.Delete(file.FullName);
-						tmpBool2 = true;
-					}
-					else
-						tmpBool2 = false;
-					if (!tmpBool2)
-						throw new System.IO.IOException("Cannot delete " + file);
-				}
-			}
-			lockFactory.ClearLock(IndexWriter.WRITE_LOCK_NAME);
-		}
-		
-		// returns the canonical version of the directory, creating it if it doesn't exist.
-		private static System.IO.FileInfo GetCanonicalPath(System.IO.FileInfo file)
-		{
-			return new System.IO.FileInfo(file.FullName);
+			if (directory.Exists)
+ 			{
+ 				System.String[] files = SupportClass.FileSupport.GetLuceneIndexFiles(directory.FullName,
IndexFileNameFilter.GetFilter()); // clear old files
+ 				if (files == null)
+ 					throw new System.IO.IOException("cannot read directory " + directory.FullName + ":
list() returned null");
+ 				for (int i = 0; i < files.Length; i++)
+ 				{
+                    System.String fileOrDir = System.IO.Path.Combine(directory.FullName,
files[i]);
+                    if (System.IO.File.Exists(fileOrDir))
+ 					{
+                        System.IO.File.Delete(fileOrDir);
+ 					}
+                    else if (System.IO.Directory.Exists(fileOrDir))
+ 					{
+                        System.IO.Directory.Delete(fileOrDir);
+ 					}
+                    // no need to throw anything - if a delete fails the exc will propogate
to the caller
+ 				}
+ 			}
+ 			lockFactory.ClearLock(IndexWriter.WRITE_LOCK_NAME);
 		}
 		
 		private bool checked_Renamed;
@@ -426,7 +461,7 @@
 		}
 		
 		/// <summary>The underlying filesystem directory </summary>
-		protected internal System.IO.FileInfo directory = null;
+		protected internal System.IO.DirectoryInfo directory = null;
 		
 		/// <deprecated> 
 		/// </deprecated>
@@ -446,9 +481,8 @@
 		/// ({@link NativeFSLockFactory});
 		/// </param>
 		/// <throws>  IOException </throws>
-		protected internal FSDirectory(System.IO.FileInfo path, LockFactory lockFactory)
+		protected internal FSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory)
 		{
-			path = GetCanonicalPath(path);
 			// new ctors use always NativeFSLockFactory as default:
 			if (lockFactory == null)
 			{
@@ -462,9 +496,8 @@
 		/// best implementation given the current environment.
 		/// The directory returned uses the {@link NativeFSLockFactory}.
 		/// 
-		/// <p>Currently this returns {@link NIOFSDirectory}
-		/// on non-Windows JREs and {@link SimpleFSDirectory}
-		/// on Windows.
+		/// <p>Currently this returns {@link SimpleFSDirectory} as
+		/// NIOFSDirectory is currently not supported.
 		/// 
 		/// <p><b>NOTE</b>: this method may suddenly change which
 		/// implementation is returned from release to release, in
@@ -479,15 +512,42 @@
 		/// 
 		/// <p>See <a href="#subclasses">above</a> 
 		/// </summary>
+		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the
3.0 release")]
 		public static FSDirectory Open(System.IO.FileInfo path)
 		{
+			System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path.FullName);
+			return Open(dir, null);
+		}
+		
+		/// <summary>Creates an FSDirectory instance, trying to pick the
+		/// best implementation given the current environment.
+		/// The directory returned uses the {@link NativeFSLockFactory}.
+		/// 
+		/// <p>Currently this returns {@link SimpleFSDirectory} as
+		/// NIOFSDirectory is currently not supported.
+		/// 
+		/// <p><b>NOTE</b>: this method may suddenly change which
+		/// implementation is returned from release to release, in
+		/// the event that higher performance defaults become
+		/// possible; if the precise implementation is important to
+		/// your application, please instantiate it directly,
+		/// instead. On 64 bit systems, it may also good to
+		/// return {@link MMapDirectory}, but this is disabled
+		/// because of officially missing unmap support in Java.
+		/// For optimal performance you should consider using
+		/// this implementation on 64 bit JVMs.
+		/// 
+		/// <p>See <a href="#subclasses">above</a> 
+		/// </summary>
+		public static FSDirectory Open(System.IO.DirectoryInfo path)
+		{
 			return Open(path, null);
 		}
 		
 		/// <summary>Just like {@link #Open(File)}, but allows you to
 		/// also specify a custom {@link LockFactory}. 
 		/// </summary>
-		public static FSDirectory Open(System.IO.FileInfo path, LockFactory lockFactory)
+		public static FSDirectory Open(System.IO.DirectoryInfo path, LockFactory lockFactory)
 		{
 			/* For testing:
 			MMapDirectory dir=new MMapDirectory(path, lockFactory);
@@ -506,7 +566,7 @@
 		}
 		
 		/* will move to ctor, when reflection is removed in 3.0 */
-		private void  Init(System.IO.FileInfo path, LockFactory lockFactory)
+		private void  Init(System.IO.DirectoryInfo path, LockFactory lockFactory)
 		{
 			
 			// Set up lockFactory with cascaded defaults: if an instance was passed in,
@@ -516,13 +576,11 @@
 			
 			directory = path;
 			
-			bool tmpBool;
-			if (System.IO.File.Exists(directory.FullName))
-				tmpBool = true;
-			else
-				tmpBool = System.IO.Directory.Exists(directory.FullName);
-			if (tmpBool && !System.IO.Directory.Exists(directory.FullName))
-				throw new NoSuchDirectoryException("file '" + directory + "' exists but is not a directory");
+            // due to differences in how Java & .NET refer to files, the checks are a
bit different
+            if (!directory.Exists && System.IO.File.Exists(directory.FullName))
+            {
+                throw new NoSuchDirectoryException("file '" + directory.FullName + "' exists
but is not a directory");
+            }
 			
 			if (lockFactory == null)
 			{
@@ -582,7 +640,7 @@
 			if (lockFactory is FSLockFactory)
 			{
 				FSLockFactory lf = (FSLockFactory) lockFactory;
-				System.IO.FileInfo dir = lf.GetLockDir();
+				System.IO.DirectoryInfo dir = lf.GetLockDir();
 				// if the lock factory has no lockDir set, use the this directory as lockDir
 				if (dir == null)
 				{
@@ -606,32 +664,42 @@
 		/// directory.
 		/// </summary>
 		/// <throws>  IOException if list() returns null  </throws>
+		[System.Obsolete("Use the method that takes a DirectoryInfo, this will be removed in the
3.0 release")]
 		public static System.String[] ListAll(System.IO.FileInfo dir)
 		{
-			bool tmpBool;
-			if (System.IO.File.Exists(dir.FullName))
-				tmpBool = true;
-			else
-				tmpBool = System.IO.Directory.Exists(dir.FullName);
-			if (!tmpBool)
-				throw new NoSuchDirectoryException("directory '" + dir + "' does not exist");
-			else if (!System.IO.Directory.Exists(dir.FullName))
-				throw new NoSuchDirectoryException("file '" + dir + "' exists but is not a directory");
-			
-			// Exclude subdirs
-            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dir.FullName);
-            System.IO.FileInfo[] files = di.GetFiles();
+			return ListAll(new System.IO.DirectoryInfo(dir.FullName));
+		}
+		
+        /// <summary>Lists all files (not subdirectories) in the
+        /// directory.  This method never returns null (throws
+        /// {@link IOException} instead).
+        /// 
+        /// </summary>
+        /// <throws>  NoSuchDirectoryException if the directory </throws>
+        /// <summary>   does not exist, or does exist but is not a
+        /// directory.
+        /// </summary>
+        /// <throws>  IOException if list() returns null  </throws>
+        public static System.String[] ListAll(System.IO.DirectoryInfo dir)
+        {
+            if (!dir.Exists)
+            {
+                throw new NoSuchDirectoryException("directory '" + dir.FullName + "' does
not exist");
+            }
+            // Exclude subdirs, only the file names, not the paths
+            System.IO.FileInfo[] files = dir.GetFiles();
             System.String[] result = new System.String[files.Length];
             for (int i = 0; i < files.Length; i++)
             {
                 result[i] = files[i].Name;
             }
-			
-			if (result == null)
-				throw new System.IO.IOException("directory '" + dir + "' exists and is a directory, but
cannot be listed: list() returned null");
-			
-			return result;
-		}
+
+            // no reason to return null, if the directory cannot be listed, an exception

+            // will be thrown on the above call to dir.GetFiles()
+            // use of LINQ to create the return value array may be a bit more efficient
+
+            return result;
+        }
 		
 		public override System.String[] List()
 		{
@@ -988,8 +1056,16 @@
 		public virtual System.IO.FileInfo GetFile()
 		{
 			EnsureOpen();
-			return directory;
+			return new System.IO.FileInfo(directory.FullName);
 		}
+
+        // Java Lucene implements GetFile() which returns a FileInfo.
+        // For Lucene.Net, GetDirectory() is more appropriate
+        public virtual System.IO.DirectoryInfo GetDirectory()
+        {
+            EnsureOpen();
+            return directory;
+        }
 		
 		/// <summary>For debug output. </summary>
 		public override System.String ToString()

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/FSLockFactory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSLockFactory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/FSLockFactory.cs Fri Nov 13 20:26:04
2009
@@ -26,7 +26,7 @@
 	{
 		
 		/// <summary> Directory for the lock files.</summary>
-		protected internal System.IO.FileInfo lockDir = null;
+		protected internal System.IO.DirectoryInfo lockDir = null;
 		
 		/// <summary> Set the lock directory. This method can be only called
 		/// once to initialize the lock directory. It is used by {@link FSDirectory}
@@ -34,7 +34,7 @@
 		/// Subclasses can also use this method to set the directory
 		/// in the constructor.
 		/// </summary>
-		protected internal virtual void  SetLockDir(System.IO.FileInfo lockDir)
+		protected internal virtual void  SetLockDir(System.IO.DirectoryInfo lockDir)
 		{
 			if (this.lockDir != null)
 				throw new System.SystemException("You can set the lock directory for this factory only
once.");
@@ -42,7 +42,7 @@
 		}
 		
 		/// <summary> Retrieve the lock directory.</summary>
-		public virtual System.IO.FileInfo GetLockDir()
+		public virtual System.IO.DirectoryInfo GetLockDir()
 		{
 			return lockDir;
 		}

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/LockStressTest.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/LockStressTest.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/LockStressTest.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/LockStressTest.cs Fri Nov 13 20:26:04
2009
@@ -85,7 +85,7 @@
 				throw new System.IO.IOException("InstantiationException when instantiating LockClass
" + lockFactoryClassName);
 			}
 			
-			System.IO.FileInfo lockDir = new System.IO.FileInfo(lockDirName);
+			System.IO.DirectoryInfo lockDir = new System.IO.DirectoryInfo(lockDirName);
 			
 			if (lockFactory is NativeFSLockFactory)
 			{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/MMapDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/MMapDirectory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/MMapDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/MMapDirectory.cs Fri Nov 13 20:26:04
2009
@@ -112,22 +112,48 @@
 		/// <param name="lockFactory">the lock factory to use, or null for the default.
 		/// </param>
 		/// <throws>  IOException </throws>
-		public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(path, lockFactory)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName),
lockFactory)
 		{
 			InitBlock();
 		}
 		
+        /// <summary>Create a new MMapDirectory for the named location.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <param name="lockFactory">the lock factory to use, or null for the default.
+        /// </param>
+        /// <throws>  IOException </throws>
+        public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path,
lockFactory)
+        {
+            InitBlock();
+        }
+		
 		/// <summary>Create a new MMapDirectory for the named location and the default lock
factory.
 		/// 
 		/// </summary>
 		/// <param name="path">the path of the directory
 		/// </param>
 		/// <throws>  IOException </throws>
-		public MMapDirectory(System.IO.FileInfo path):base(path, null)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public MMapDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName),
null)
 		{
 			InitBlock();
 		}
 		
+        /// <summary>Create a new MMapDirectory for the named location and the default
lock factory.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <throws>  IOException </throws>
+        public MMapDirectory(System.IO.DirectoryInfo path) : base(path, null)
+        {
+            InitBlock();
+        }
+		
 		// back compatibility so FSDirectory can instantiate via reflection
 		/// <deprecated> 
 		/// </deprecated>
@@ -488,8 +514,8 @@
 		public override IndexInput OpenInput(System.String name, int bufferSize)
 		{
 			EnsureOpen();
-			System.IO.FileInfo f = new System.IO.FileInfo(System.IO.Path.Combine(GetFile().FullName,
name));
-			System.IO.FileStream raf = new System.IO.FileStream(f.FullName, System.IO.FileMode.Open,
System.IO.FileAccess.Read);
+			System.String path = System.IO.Path.Combine(GetDirectory().FullName, name);
+			System.IO.FileStream raf = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
 			try
 			{
 				return (raf.Length <= (long) maxBBuf)?(IndexInput) new MMapIndexInput(this, raf):(IndexInput)
new MultiMMapIndexInput(this, raf, maxBBuf);

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NIOFSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/NIOFSDirectory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NIOFSDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NIOFSDirectory.cs Fri Nov 13 20:26:04
2009
@@ -46,9 +46,22 @@
 		/// <param name="lockFactory">the lock factory to use, or null for the default.
 		/// </param>
 		/// <throws>  IOException </throws>
-		public NIOFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(path, lockFactory)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public NIOFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName),
lockFactory)
 		{
 		}
+
+        /// <summary>Create a new NIOFSDirectory for the named location.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <param name="lockFactory">the lock factory to use, or null for the default.
+        /// </param>
+        /// <throws>  IOException </throws>
+        public NIOFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path,
lockFactory)
+        {
+        }
 		
 		/// <summary>Create a new NIOFSDirectory for the named location and the default lock
factory.
 		/// 
@@ -56,9 +69,20 @@
 		/// <param name="path">the path of the directory
 		/// </param>
 		/// <throws>  IOException </throws>
-		public NIOFSDirectory(System.IO.FileInfo path):base(path, null)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public NIOFSDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName),
null)
 		{
 		}
+
+        /// <summary>Create a new NIOFSDirectory for the named location and the default
lock factory.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <throws>  IOException </throws>
+        public NIOFSDirectory(System.IO.DirectoryInfo path) : base(path, null)
+        {
+        }
 		
 		// back compatibility so FSDirectory can instantiate via reflection
 		/// <deprecated> 

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NativeFSLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/NativeFSLockFactory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NativeFSLockFactory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/NativeFSLockFactory.cs Fri Nov 13 20:26:04
2009
@@ -112,7 +112,7 @@
 		/// directory itsself. Be sure to create one instance for each directory
 		/// your create!
 		/// </summary>
-		public NativeFSLockFactory():this((System.IO.FileInfo) null)
+		public NativeFSLockFactory():this((System.IO.DirectoryInfo) null)
 		{
 		}
 		
@@ -122,7 +122,7 @@
 		/// </summary>
 		/// <param name="lockDirName">where lock files are created.
 		/// </param>
-		public NativeFSLockFactory(System.String lockDirName):this(new System.IO.FileInfo(lockDirName))
+		public NativeFSLockFactory(System.String lockDirName):this(new System.IO.DirectoryInfo(lockDirName))
 		{
 		}
 		
@@ -132,11 +132,22 @@
 		/// </summary>
 		/// <param name="lockDir">where lock files are created.
 		/// </param>
-		public NativeFSLockFactory(System.IO.FileInfo lockDir)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public NativeFSLockFactory(System.IO.FileInfo lockDir) : this(new System.IO.DirectoryInfo(lockDir.FullName))
 		{
-			SetLockDir(lockDir);
 		}
 		
+        /// <summary> Create a NativeFSLockFactory instance, storing lock
+        /// files into the specified lockDir:
+        /// 
+        /// </summary>
+        /// <param name="lockDir">where lock files are created.
+        /// </param>
+        public NativeFSLockFactory(System.IO.DirectoryInfo lockDir)
+        {
+            SetLockDir(lockDir);
+        }
+		
 		public override Lock MakeLock(System.String lockName)
 		{
 			lock (this)
@@ -200,7 +211,7 @@
 		private System.IO.FileStream channel;
 		private bool lock_Renamed;
 		private System.IO.FileInfo path;
-		private System.IO.FileInfo lockDir;
+		private System.IO.DirectoryInfo lockDir;
 		
 		/*
 		* The javadocs for FileChannel state that you should have
@@ -213,13 +224,18 @@
 		* instance) have set the same lock dir and lock prefix.
 		*/
 		private static System.Collections.Hashtable LOCK_HELD = new System.Collections.Hashtable();
-		
-		public NativeFSLock(System.IO.FileInfo lockDir, System.String lockFileName)
+
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public NativeFSLock(System.IO.FileInfo lockDir, System.String lockFileName):this(new System.IO.DirectoryInfo(lockDir.FullName),
lockFileName)
 		{
-			this.lockDir = lockDir;
-			path = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName));
 		}
 		
+        public NativeFSLock(System.IO.DirectoryInfo lockDir, System.String lockFileName)
+        {
+            this.lockDir = lockDir;
+            path = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName));
+        }
+		
 		private bool LockExists()
 		{
 			lock (this)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/SimpleFSDirectory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSDirectory.cs Fri Nov 13 20:26:04
2009
@@ -38,17 +38,31 @@
 		/// <param name="lockFactory">the lock factory to use, or null for the default.
 		/// </param>
 		/// <throws>  IOException </throws>
-		public SimpleFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(path, lockFactory)
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public SimpleFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName),
lockFactory)
 		{
 		}
 		
+        /// <summary>Create a new SimpleFSDirectory for the named location.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <param name="lockFactory">the lock factory to use, or null for the default.
+        /// </param>
+        /// <throws>  IOException </throws>
+        public SimpleFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) :
base(path, lockFactory)
+        {
+        }
+		
 		/// <summary>Create a new SimpleFSDirectory for the named location and the default
lock factory.
 		/// 
 		/// </summary>
 		/// <param name="path">the path of the directory
 		/// </param>
 		/// <throws>  IOException </throws>
-		public SimpleFSDirectory(System.IO.FileInfo path):base(path, null)
+        [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public SimpleFSDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName),
null)
 		{
 		}
 		
@@ -59,6 +73,16 @@
 		{
 		}
 		
+        /// <summary>Create a new SimpleFSDirectory for the named location and the
default lock factory.
+        /// 
+        /// </summary>
+        /// <param name="path">the path of the directory
+        /// </param>
+        /// <throws>  IOException </throws>
+        public SimpleFSDirectory(System.IO.DirectoryInfo path) : base(path, null)
+        {
+        }
+
 		/// <summary>Creates an IndexOutput for the file with the given name. </summary>
 		public override IndexOutput CreateOutput(System.String name)
 		{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Store/SimpleFSLockFactory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSLockFactory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Store/SimpleFSLockFactory.cs Fri Nov 13 20:26:04
2009
@@ -59,24 +59,33 @@
 		/// directory itsself. Be sure to create one instance for each directory
 		/// your create!
 		/// </summary>
-		public SimpleFSLockFactory():this((System.IO.FileInfo) null)
+		public SimpleFSLockFactory():this((System.IO.DirectoryInfo) null)
 		{
 		}
 		
 		/// <summary> Instantiate using the provided directory (as a File instance).</summary>
 		/// <param name="lockDir">where lock files should be created.
 		/// </param>
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
 		public SimpleFSLockFactory(System.IO.FileInfo lockDir)
 		{
-			SetLockDir(lockDir);
+			SetLockDir(new System.IO.DirectoryInfo(lockDir.FullName));
 		}
+
+        /// <summary> Instantiate using the provided directory (as a File instance).</summary>
+        /// <param name="lockDir">where lock files should be created.
+        /// </param>
+        public SimpleFSLockFactory(System.IO.DirectoryInfo lockDir)
+        {
+            SetLockDir(lockDir);
+        }
 		
 		/// <summary> Instantiate using the provided directory name (String).</summary>
 		/// <param name="lockDirName">where lock files should be created.
 		/// </param>
 		public SimpleFSLockFactory(System.String lockDirName)
 		{
-			lockDir = new System.IO.FileInfo(lockDirName);
+			lockDir = new System.IO.DirectoryInfo(lockDirName);
 			SetLockDir(lockDir);
 		}
 		
@@ -134,13 +143,18 @@
 	{
 		
 		internal System.IO.FileInfo lockFile;
-		internal System.IO.FileInfo lockDir;
-		
-		public SimpleFSLock(System.IO.FileInfo lockDir, System.String lockFileName)
+		internal System.IO.DirectoryInfo lockDir;
+
+		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
+		public SimpleFSLock(System.IO.FileInfo lockDir, System.String lockFileName) : this(new
System.IO.DirectoryInfo(lockDir.FullName), lockFileName)
 		{
-			this.lockDir = lockDir;
-			lockFile = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName));
 		}
+
+        public SimpleFSLock(System.IO.DirectoryInfo lockDir, System.String lockFileName)
+        {
+            this.lockDir = new System.IO.DirectoryInfo(lockDir.FullName);
+            lockFile = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName));
+        }
 		
 		public override bool Obtain()
 		{

Modified: incubator/lucene.net/trunk/C#/src/Test/Store/TestDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestDirectory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestDirectory.cs Fri Nov 13 20:26:04 2009
@@ -63,11 +63,12 @@
 		{
 			System.IO.FileInfo path = new System.IO.FileInfo(SupportClass.AppSettings.Get("tempDir",
""));
 			
-			int sz = 3;
+			int sz = 2;
 			Directory[] dirs = new Directory[sz];
 			
 			dirs[0] = new SimpleFSDirectory(path, null);
-			dirs[1] = new NIOFSDirectory(path, null);
+			// dirs[1] = new NIOFSDirectory(path, null);
+            System.Console.WriteLine("Skipping NIOFSDirectory() test under Lucene.Net");
 			dirs[2] = new MMapDirectory(path, null);
 			
 			for (int i = 0; i < sz; i++)

Modified: incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestLockFactory.cs?rev=835980&r1=835979&r2=835980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestLockFactory.cs Fri Nov 13 20:26:04 2009
@@ -368,7 +368,7 @@
 		
 		public virtual void  _testStressLocks(LockFactory lockFactory, System.IO.FileInfo indexDir)
 		{
-			FSDirectory fs1 = FSDirectory.Open(indexDir, lockFactory);
+			FSDirectory fs1 = FSDirectory.Open(new System.IO.DirectoryInfo(indexDir.FullName), lockFactory);
 			
 			// First create a 1 doc index:
 			IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
@@ -426,9 +426,9 @@
 			
 			System.IO.FileInfo fdir1 = _TestUtil.GetTempDir("TestLockFactory.8");
 			System.IO.FileInfo fdir2 = _TestUtil.GetTempDir("TestLockFactory.8.Lockdir");
-			Directory dir1 = FSDirectory.Open(fdir1, new NativeFSLockFactory(fdir1));
+			Directory dir1 = FSDirectory.Open(new System.IO.DirectoryInfo(fdir1.FullName), new NativeFSLockFactory(fdir1));
 			// same directory, but locks are stored somewhere else. The prefix of the lock factory
should != null
-			Directory dir2 = FSDirectory.Open(fdir1, new NativeFSLockFactory(fdir2));
+			Directory dir2 = FSDirectory.Open(new System.IO.DirectoryInfo(fdir2.FullName), new NativeFSLockFactory(fdir2));
 			
 			System.String prefix1 = dir1.GetLockFactory().GetLockPrefix();
 			Assert.IsNull(prefix1, "Lock prefix for lockDir same as directory should be null");



Mime
View raw message