Mercurial > 510Connectbot
diff src/ch/ethz/ssh2/SFTPv3FileAttributes.java @ 307:071eccdff8ea ganymed
fix java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 30 Jul 2014 14:16:58 -0700 |
parents | d2b303406d63 |
children |
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/SFTPv3FileAttributes.java Wed Jul 30 12:09:51 2014 -0700 +++ b/src/ch/ethz/ssh2/SFTPv3FileAttributes.java Wed Jul 30 14:16:58 2014 -0700 @@ -89,9 +89,10 @@ * that this entry represents a directory. */ public boolean isDirectory() { - if(permissions == null) { + if (permissions == null) { return false; } + return ((permissions & 0040000) == 0040000); } @@ -102,9 +103,10 @@ * that this entry represents a regular file. */ public boolean isRegularFile() { - if(permissions == null) { + if (permissions == null) { return false; } + return ((permissions & 0100000) == 0100000); } @@ -115,9 +117,10 @@ * that this entry represents a symlink. */ public boolean isSymlink() { - if(permissions == null) { + if (permissions == null) { return false; } + return ((permissions & 0120000) == 0120000); } @@ -128,22 +131,20 @@ * @return <code>NULL</code> if permissions are not available. */ public String getOctalPermissions() { - if(permissions == null) { + if (permissions == null) { return null; } + String res = Integer.toString(permissions.intValue() & 0177777, 8); - StringBuilder sb = new StringBuilder(); - int leadingZeros = 7 - res.length(); - while(leadingZeros > 0) { + while (leadingZeros > 0) { sb.append('0'); leadingZeros--; } sb.append(res); - return sb.toString(); } @@ -179,25 +180,30 @@ */ public SFTPv3FileAttributes(final TypesReader tr) throws IOException { int flags = tr.readUINT32(); - if((flags & AttribFlags.SSH_FILEXFER_ATTR_SIZE) != 0) { + + if ((flags & AttribFlags.SSH_FILEXFER_ATTR_SIZE) != 0) { this.size = tr.readUINT64(); } - if((flags & AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID) != 0) { + + if ((flags & AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID) != 0) { this.uid = tr.readUINT32(); this.gid = tr.readUINT32(); } - if((flags & AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS) != 0) { + + if ((flags & AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS) != 0) { this.permissions = tr.readUINT32(); } - if((flags & AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME) != 0) { + + if ((flags & AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME) != 0) { this.atime = tr.readUINT32(); this.mtime = tr.readUINT32(); + } - } - if((flags & AttribFlags.SSH_FILEXFER_ATTR_EXTENDED) != 0) { + if ((flags & AttribFlags.SSH_FILEXFER_ATTR_EXTENDED) != 0) { int count = tr.readUINT32(); + // Read it anyway to detect corrupt packets - while(count > 0) { + while (count > 0) { tr.readByteString(); tr.readByteString(); count--; @@ -215,36 +221,43 @@ public byte[] toBytes() { TypesWriter tw = new TypesWriter(); int attrFlags = 0; - if(this.size != null) { + + if (this.size != null) { attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE; } - if((this.uid != null) && (this.gid != null)) { + + if ((this.uid != null) && (this.gid != null)) { attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID; } - if(this.permissions != null) { + + if (this.permissions != null) { attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS; } - if((this.atime != null) && (this.mtime != null)) { + + if ((this.atime != null) && (this.mtime != null)) { attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME; } + tw.writeUINT32(attrFlags); - if(this.size != null) { + + if (this.size != null) { tw.writeUINT64(this.size); } - if((this.uid != null) && (this.gid != null)) { + if ((this.uid != null) && (this.gid != null)) { tw.writeUINT32(this.uid); tw.writeUINT32(this.gid); } - if(this.permissions != null) { + if (this.permissions != null) { tw.writeUINT32(this.permissions); } - if((this.atime != null) && (this.mtime != null)) { + if ((this.atime != null) && (this.mtime != null)) { tw.writeUINT32(this.atime); tw.writeUINT32(this.mtime); } + return tw.getBytes(); }