From 1ec9086829e0ffc63c8e1ffa52e71e5b73877a0b Mon Sep 17 00:00:00 2001 From: Otis Gospodnetic Date: Fri, 15 Feb 2002 18:59:42 +0000 Subject: [PATCH] - Added public static boolean isLocked(String) method. PR: Obtained from: Submitted by: Colin Britton Reviewed by: otis git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149690 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/IndexReader.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.java index fdbd026ef3a..b71e435f1d6 100644 --- a/src/java/org/apache/lucene/index/IndexReader.java +++ b/src/java/org/apache/lucene/index/IndexReader.java @@ -310,6 +310,16 @@ abstract public class IndexReader { return directory.fileExists("write.lock"); } + /** + * Returns true iff the index in the named directory is + * currently locked. + * @param directory the directory to check for a lock + * @throws IOException if there is a problem with accessing the index + */ + public static boolean isLocked(String directory) throws IOException { + return (new File(directory, "write.lock")).exists(); + } + /** * Forcibly unlocks the index in the named directory. *