You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by bm...@apache.org on 2005/06/09 20:59:11 UTC

svn commit: r189793 - /lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java

Author: bmesser
Date: Thu Jun  9 11:59:10 2005
New Revision: 189793

URL: http://svn.apache.org/viewcvs?rev=189793&view=rev
Log:
use new filename filter in org.apache.lucene.index.IndexFileNameFilter

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java?rev=189793&r1=189792&r2=189793&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java Thu Jun  9 11:59:10 2005
@@ -16,17 +16,16 @@
  * limitations under the License.
  */
 
-import java.io.FilenameFilter;
-import java.io.IOException;
 import java.io.File;
-import java.io.RandomAccessFile;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.util.Hashtable;
+import java.io.IOException;
+import java.io.RandomAccessFile;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.util.Hashtable;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexFileNameFilter;
 import org.apache.lucene.util.Constants;
 
 /**
@@ -38,28 +37,7 @@
  * @author Doug Cutting
  */
 public class FSDirectory extends Directory {
-
-  /**
-   * Filter that only accepts filenames created by Lucene.
-   */
-  private class LuceneFileFilter implements FilenameFilter {
-
-    /* (non-Javadoc)
-     * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
-     */
-    public boolean accept(File dir, String name) {
-      for (int i = 0; i < IndexReader.FILENAME_EXTENSIONS.length; i++) {
-        if (name.endsWith("."+IndexReader.FILENAME_EXTENSIONS[i]))
-          return true;
-      }
-      if (name.equals(Constants.INDEX_DELETABLE_FILENAME)) return true;
-      else if (name.equals(Constants.INDEX_SEGMENTS_FILENAME)) return true;
-      else if (name.matches(".+\\.f\\d+")) return true;
-      return false;
-    }
-
-  }
-
+    
   /** This cache of directories ensures that there is a unique Directory
    * instance per path, so that synchronization on the Directory can be used to
    * synchronize access between readers and writers.
@@ -184,7 +162,7 @@
     if (!directory.isDirectory())
       throw new IOException(directory + " not a directory");
 
-    String[] files = directory.list(new LuceneFileFilter());            // clear old files
+    String[] files = directory.list(new IndexFileNameFilter());            // clear old files
     for (int i = 0; i < files.length; i++) {
       File file = new File(directory, files[i]);
       if (!file.delete())