Search in sources :

Example 1 with UnsignedInteger32

use of com.sshtools.common.util.UnsignedInteger32 in project agileway by fangjinuo.

the class SynergySftps method toSftpFileAttributes.

public static SftpFileAttributes toSftpFileAttributes(FileAttrs attrs, String encoding) {
    int fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_UNKNOWN;
    switch(attrs.getFileType()) {
        case REGULAR:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_REGULAR;
            break;
        case DIRECTORY:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_DIRECTORY;
            break;
        case SYMBOLIC_LINK:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_SYMLINK;
            break;
        case FIFO_SPECIAL:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_FIFO;
            break;
        case BLOCK_SPECIAL:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_BLOCK_DEVICE;
            break;
        case CHAR_SPECIAL:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_CHAR_DEVICE;
            break;
        case SOCKET_SPECIAL:
            fileType = SftpFileAttributes.SSH_FILEXFER_TYPE_SOCKET;
            break;
        default:
            break;
    }
    SftpFileAttributes attributes = new SftpFileAttributes(fileType, encoding);
    if (attrs.getSize() != null) {
        attributes.setSize(new UnsignedInteger64(attrs.getSize()));
    }
    UnsignedInteger64 atime = null;
    UnsignedInteger64 mtime = null;
    if (attrs.getAccessTime() != null) {
        atime = new UnsignedInteger64(attrs.getAccessTime());
    }
    if (attrs.getModifyTime() != null) {
        mtime = new UnsignedInteger64(attrs.getModifyTime());
    }
    attributes.setTimes(atime, mtime);
    if (attrs.getGid() != null) {
        attributes.setGID(attrs.getGid().toString());
    }
    if (attrs.getUid() != null) {
        attributes.setUID(attrs.getUid().toString());
    }
    FileMode fileMode = attrs.getFileMode();
    attributes.setPermissions(new UnsignedInteger32(fileMode.getPermissionsMask()));
    return attributes;
}
Also used : FileMode(com.jn.agileway.ssh.client.sftp.attrs.FileMode) SftpFileAttributes(com.sshtools.common.sftp.SftpFileAttributes) UnsignedInteger64(com.sshtools.common.util.UnsignedInteger64) UnsignedInteger32(com.sshtools.common.util.UnsignedInteger32)

Aggregations

FileMode (com.jn.agileway.ssh.client.sftp.attrs.FileMode)1 SftpFileAttributes (com.sshtools.common.sftp.SftpFileAttributes)1 UnsignedInteger32 (com.sshtools.common.util.UnsignedInteger32)1 UnsignedInteger64 (com.sshtools.common.util.UnsignedInteger64)1