Example usage for org.apache.commons.net.ftp FTPFile getHardLinkCount

List of usage examples for org.apache.commons.net.ftp FTPFile getHardLinkCount

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPFile getHardLinkCount.

Prototype

public int getHardLinkCount() 

Source Link

Document

Return the number of hard links to this file.

Usage

From source file:nl.nn.adapterframework.filesystem.FtpFileSystem.java

@Override
public Map<String, Object> getAdditionalFileProperties(FTPFile f) {
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("user", f.getUser());
    attributes.put("group", f.getGroup());
    attributes.put("type", f.getType());
    attributes.put("rawListing", f.getRawListing());
    attributes.put("link", f.getLink());
    attributes.put("hardLinkCount", f.getHardLinkCount());
    return attributes;
}

From source file:org.paxle.crawler.ftp.impl.FtpUrlConnection.java

private static void formatStdDirlisting(final OutputStream into, final FTPListParseEngine fileParseEngine) {
    final Formatter writer = new Formatter(into);
    FTPFile[] files;/* www.  ja  v a 2 s . com*/
    while (fileParseEngine.hasNext()) {
        files = fileParseEngine.getNext(16);
        for (final FTPFile file : files) {
            if (file == null)
                continue;

            // directory
            char c;
            switch (file.getType()) {
            case FTPFile.DIRECTORY_TYPE:
                c = 'd';
                break;
            case FTPFile.SYMBOLIC_LINK_TYPE:
                c = 's';
                break;
            default:
                c = '-';
                break;
            }
            writer.format("%c", Character.valueOf(c));

            // permissions
            for (final int access : FILE_ACCESS_MODES) {
                writer.format("%c%c%c",
                        Character.valueOf(file.hasPermission(access, FTPFile.READ_PERMISSION) ? 'r' : '-'),
                        Character.valueOf(file.hasPermission(access, FTPFile.WRITE_PERMISSION) ? 'w' : '-'),
                        Character.valueOf(file.hasPermission(access, FTPFile.EXECUTE_PERMISSION) ? 'x' : '-'));
            }

            // other information
            writer.format("  %2d", Integer.valueOf(file.getHardLinkCount()));
            writer.format("  %8s", file.getUser());
            writer.format("  %8s", file.getGroup());
            writer.format("  %12d", Long.valueOf(file.getSize()));
            writer.format("  %1$tY-%1$tm-%1$td %1$tH:%1$tM",
                    Long.valueOf(file.getTimestamp().getTimeInMillis()));
            writer.format("  %s", file.getName());

            writer.format("%s", System.getProperty("line.separator"));
        }
    }

    writer.flush();
}