private void doGetChildren()

in commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileObject.java [236:267]


    private void doGetChildren() throws IOException {
        if (childMap != null) {
            return;
        }
        final FtpClient client = getAbstractFileSystem().getClient();
        try {
            final String path = ftpFile != null && ftpFile.isSymbolicLink()
                    ? getFileSystem().getFileSystemManager().resolveName(getParent().getName(), ftpFile.getLink()).getPath()
                    : relPath;
            final FTPFile[] tmpChildren = client.listFiles(path);
            if (ArrayUtils.isEmpty(tmpChildren)) {
                childMap = EMPTY_FTP_FILE_MAP;
            } else {
                childMap = new TreeMap<>();
                // Remove '.' and '..' elements
                for (int i = 0; i < tmpChildren.length; i++) {
                    final FTPFile child = tmpChildren[i];
                    if (child == null) {
                        if (log.isDebugEnabled()) {
                            log.debug(Messages.getString("vfs.provider.ftp/invalid-directory-entry.debug", Integer.valueOf(i), relPath));
                        }
                        continue;
                    }
                    if (!".".equals(child.getName()) && !"..".equals(child.getName())) {
                        childMap.put(child.getName(), child);
                    }
                }
            }
        } finally {
            getAbstractFileSystem().putClient(client);
        }
    }