lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r208904 - /lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
Date Sun, 03 Jul 2005 10:33:37 GMT
Author: dnaber
Date: Sun Jul  3 03:33:33 2005
New Revision: 208904

URL: http://svn.apache.org/viewcvs?rev=208904&view=rev
Log:
simplify usage of the main method: directory doesn't need to be specified explicitly anymore

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=208904&r1=208903&r2=208904&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Sun Jul  3 03:33:33
2005
@@ -23,7 +23,6 @@
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.Lock;
-import org.apache.lucene.util.Constants;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -687,24 +686,22 @@
    * Add the -extract flag to extract files to the current working directory.
    * In order to make the extracted version of the index work, you have to copy
    * the segments file from the compound index into the directory where the extracted files
are stored.
-   * @param args
+   * @param args Usage: org.apache.lucene.index.IndexReader [-extract] <cfsfile>
    */
   public static void main(String [] args) {
-    String dirname = null, filename = null;
+    String filename = null;
     boolean extract = false;
 
     for (int i = 0; i < args.length; ++i) {
       if (args[i].equals("-extract")) {
         extract = true;
-      } else if (dirname == null) {
-        dirname = args[i];
       } else if (filename == null) {
         filename = args[i];
       }
     }
 
-    if (dirname == null || filename == null) {
-      System.out.println("Usage: org.apache.lucene.index.IndexReader [-extract] <directory>
<cfsfile>");
+    if (filename == null) {
+      System.out.println("Usage: org.apache.lucene.index.IndexReader [-extract] <cfsfile>");
       return;
     }
 
@@ -712,8 +709,10 @@
     CompoundFileReader cfr = null;
       
     try {
+      File file = new File(filename);
+      String dirname = file.getAbsoluteFile().getParent();
+      filename = file.getName();
       dir = FSDirectory.getDirectory(dirname, false);
-
       cfr = new CompoundFileReader(dir, filename);
 
       String [] files = cfr.list();



Mime
View raw message