public Set<RelativeDirectory> getAllDirectories() {
        lock.lock();
        try {
            checkIndex();
            if (allDirs == Collections.EMPTY_SET) {
                allDirs = new HashSet<RelativeDirectory>(directories.keySet());
            }

            return allDirs;
        }
        catch (IOException e) {
            return Collections.<RelativeDirectory>emptySet();
        }
        finally {
            lock.unlock();
        }
    }