private FSDirectory(File path, boolean create) throws IOException { directory = path; if (LOCK_DIR == null) { lockDir = directory; } else { lockDir = new File(LOCK_DIR); } if (create) { create(); } if (!directory.isDirectory()) throw new IOException(path + " not a directory"); }
/** Returns the directory instance for the named location. * * @deprecated Use IndexWriter's create flag, instead, to * create a new index. * * @param file the path to the directory. * @param create if true, create, or erase any existing contents. * @return the FSDirectory for the named file. */ public static FSDirectory getDirectory(File file, boolean create) throws IOException { FSDirectory dir = getDirectory(file, null); // This is now deprecated (creation should only be done // by IndexWriter): if (create) { dir.create(); } return dir; }
/** Returns the directory instance for the named location. * * @deprecated Use IndexWriter's create flag, instead, to * create a new index. * * @param file the path to the directory. * @param create if true, create, or erase any existing contents. * @return the FSDirectory for the named file. */ public static FSDirectory getDirectory(File file, boolean create) throws IOException { FSDirectory dir = getDirectory(file, null); // This is now deprecated (creation should only be done // by IndexWriter): if (create) { dir.create(); } return dir; }
/** Returns the directory instance for the named location. * * @deprecated Use IndexWriter's create flag, instead, to * create a new index. * * @param file the path to the directory. * @param create if true, create, or erase any existing contents. * @return the FSDirectory for the named file. */ public static FSDirectory getDirectory(File file, boolean create) throws IOException { FSDirectory dir = getDirectory(file, null); // This is now deprecated (creation should only be done // by IndexWriter): if (create) { dir.create(); } return dir; }
/** Returns the directory instance for the named location. * * @deprecated Use IndexWriter's create flag, instead, to * create a new index. * * @param file the path to the directory. * @param create if true, create, or erase any existing contents. * @return the FSDirectory for the named file. */ public static FSDirectory getDirectory(File file, boolean create) throws IOException { FSDirectory dir = getDirectory(file, null); // This is now deprecated (creation should only be done // by IndexWriter): if (create) { dir.create(); } return dir; }
/** Returns the directory instance for the named location. * * <p>Directories are cached, so that, for a given canonical path, the same * FSDirectory instance will always be returned. This permits * synchronization on directories. * * @param file the path to the directory. * @param create if true, create, or erase any existing contents. * @return the FSDirectory for the named file. */ public static FSDirectory getDirectory(File file, boolean create) throws IOException { file = new File(file.getCanonicalPath()); FSDirectory dir; synchronized (DIRECTORIES) { dir = (FSDirectory)DIRECTORIES.get(file); if (dir == null) { dir = new FSDirectory(file, create); DIRECTORIES.put(file, dir); } else if (create) { dir.create(); } } synchronized (dir) { dir.refCount++; } return dir; }