if (directory == null) {
File file;
try {
file = FileUtils.createDirIfNotExists(directoryName, "");
} catch (PersistenceException e) {
throw new IndexException("Cannot create index directory " + directoryName, e);
}
try {
directory = FSDirectory.open(file);
} catch (IOException e) {
throw new IndexException("Cannot open index directory " + directoryName, e);
}
}
}