code: public Directory getDirectory(final String name) throws IOException
     {
        return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Directory>()
        {
           public Directory run() throws Exception
           {
              File dir;
              if (name.equals("."))
              {
                 dir = baseDir;
              }
              else
              {
                 dir = new File(baseDir, name);
              }
              // FSDirectory itself doesnt create dirs now
              if (!dir.exists())
              {
                 if (!dir.mkdirs())
                 {
                    throw new IOException("Cannot create directory: " + dir);
                 }
              }
              LockFactory lockFactory =
                 (LOCK_FACTORY_CLASS == null) ? new NativeFSLockFactory() : (LockFactory)LOCK_FACTORY_CLASS.newInstance();
  
              if (FS_DIRECTORY_CLASS == null)
              {
                 return FSDirectory.open(dir, lockFactory);
              }
              else
              {
                 Constructor<? extends FSDirectory> constructor =
                    FS_DIRECTORY_CLASS.getConstructor(File.class, LockFactory.class);
                 return constructor.newInstance(dir, lockFactory);
              }
           }
        });
     }
docs: {@inheritDoc}