code: public static long getCurrentSegmentGeneration(Directory directory)
        throws IOException {
      String[] files = directory.list();
      if (files == null)
        throw new IOException("cannot read directory " + directory
            + ": list() returned null");
      return getCurrentSegmentGeneration(files);
    }
docs: Get the generation (N) of the current segments_N file in the directory.
  
  @param directory -- directory to search for the latest segments_N file