public List getFileList()

in wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java [275:319]


    public List<String> getFileList(String destinationDirectory)
            throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
        if (destinationDirectory.length() == 0) {
            destinationDirectory = ".";
        }

        String filename = ScpHelper.getResourceFilename(destinationDirectory);

        String dir = ScpHelper.getResourceDirectory(destinationDirectory);

        // we already setuped the root directory. Ignore beginning /
        if (dir.length() > 0 && dir.charAt(0) == ScpHelper.PATH_SEPARATOR) {
            dir = dir.substring(1);
        }

        try {
            SftpATTRS attrs = changeToRepositoryDirectory(dir, filename);
            if ((attrs.getPermissions() & S_IFDIR) == 0) {
                throw new TransferFailedException("Remote path is not a directory:" + dir);
            }

            @SuppressWarnings("unchecked")
            List<ChannelSftp.LsEntry> fileList = channel.ls(filename);
            List<String> files = new ArrayList<>(fileList.size());
            for (ChannelSftp.LsEntry entry : fileList) {
                String name = entry.getFilename();
                if (entry.getAttrs().isDir()) {
                    if (!name.equals(".") && !name.equals("..")) {
                        if (!name.endsWith("/")) {
                            name += "/";
                        }
                        files.add(name);
                    }
                } else {
                    files.add(name);
                }
            }
            return files;
        } catch (SftpException e) {
            String msg = "Error occurred while listing '" + destinationDirectory + "' " + "on remote repository: "
                    + getRepository().getUrl() + ": " + e.getMessage();

            throw new TransferFailedException(msg, e);
        }
    }