use of com.jn.agileway.ssh.client.sftp.attrs.FileAttrs in project agileway by fangjinuo.
the class Sftps method getPosixPermission.
public static PosixFilePermissions getPosixPermission(SftpFile sftpFile) throws IOException {
FileAttrs attrs = sftpFile.getAttributes();
int[] groupIds = sftpFile.getSession().getSshConnection().getGroupIds();
boolean inGroup = Collects.newArrayList(PrimitiveArrays.wrap(groupIds)).contains(attrs.getGid());
int uid = sftpFile.getSession().getSshConnection().getUid();
boolean isOwner = attrs.getUid() == uid;
return new PosixFilePermissions(attrs.getFileMode().getPermissionsMask(), isOwner, inGroup);
}
use of com.jn.agileway.ssh.client.sftp.attrs.FileAttrs in project agileway by fangjinuo.
the class Sftps method chown.
public static void chown(final SftpSession session, String path, int uid) throws IOException {
FileAttrs attrs = session.stat(path);
FileAttrs attrs2 = new FileAttrs();
attrs2.setUid(uid);
attrs2.setGid(attrs.getGid());
session.setStat(path, attrs2);
}
Aggregations