/// <summary>Create a new FSDirectory for the named location (ctor for subclasses).</summary> /// <param name="path">the path of the directory /// </param> /// <param name="lockFactory">the lock factory to use, or null for the default /// (<see cref="NativeFSLockFactory" />); /// </param> /// <throws> IOException </throws> protected internal FSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } // Set up lockFactory with cascaded defaults: if an instance was passed in, // use that; else if locks are disabled, use NoLockFactory; else if the // system property Lucene.Net.Store.FSDirectoryLockFactoryClass is set, // instantiate that; else, use SimpleFSLockFactory: internalDirectory = path; // due to differences in how Java & .NET refer to files, the checks are a bit different if (!internalDirectory.Exists && System.IO.File.Exists(internalDirectory.FullName)) { throw new NoSuchDirectoryException("file '" + internalDirectory.FullName + "' exists but is not a directory"); } SetLockFactory(lockFactory); // for filesystem based LockFactory, delete the lockPrefix, if the locks are placed // in index dir. If no index dir is given, set ourselves if (lockFactory is FSLockFactory) { FSLockFactory lf = (FSLockFactory)lockFactory; System.IO.DirectoryInfo dir = lf.LockDir; // if the lock factory has no lockDir set, use the this directory as lockDir if (dir == null) { lf.LockDir = this.internalDirectory; lf.LockPrefix = null; } else if (dir.FullName.Equals(this.internalDirectory.FullName)) { lf.LockPrefix = null; } } }