internal static SftpATTRS getATTR(Buffer buf) { SftpATTRS attr = new SftpATTRS(); attr.m_flags = buf.getInt(); if ((attr.m_flags & SSH_FILEXFER_ATTR_SIZE) != 0) attr.m_size = buf.getLong(); if ((attr.m_flags & SSH_FILEXFER_ATTR_UIDGID) != 0) { attr.m_uid = buf.getInt(); attr.m_gid = buf.getInt(); } if ((attr.m_flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) attr.m_permissions = buf.getInt(); if ((attr.m_flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) attr.m_atime = buf.getInt(); if ((attr.m_flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) attr.m_mtime = buf.getInt(); if ((attr.m_flags & SSH_FILEXFER_ATTR_EXTENDED) != 0) { int count = buf.getInt(); if (count > 0) { attr.m_extended = new String[count * 2]; for (int i = 0; i < count; i++) { attr.m_extended[i * 2] = Util.getString(buf.getString()); attr.m_extended[i * 2 + 1] = Util.getString(buf.getString()); } } } return attr; }
internal LsEntry(string filename, string longname, SftpATTRS attrs) { Filename = filename; Longname = longname; Attrs = attrs; }
private void _setStat(string path, SftpATTRS attr) { try { sendSETSTAT(Util.getBytesUTF8(path), attr); Header _header = new Header(); _header = fillHeader(m_buffer, _header); int length = _header.Length; int type = _header.HeaderType; m_buffer.rewind(); fill(m_buffer.m_buffer, 0, length); if (type != SSH_FXP_STATUS) { throw new SftpException(ChannelSftpResult.SSH_FX_FAILURE, ""); } int i = m_buffer.getInt(); if (i != (int)ChannelSftpResult.SSH_FX_OK) { throwStatusError(m_buffer, i); } } catch (Exception e) { if (e is SftpException) throw (SftpException)e; throw new SftpException(ChannelSftpResult.SSH_FX_FAILURE, ""); } }
private void sendSETSTAT(byte[] path, SftpATTRS attr) { m_packet.reset(); putHEAD(SSH_FXP_SETSTAT, 9 + path.Length + attr.Length()); m_buffer.putInt(m_seq++); m_buffer.putString(path); // path attr.dump(m_buffer); m_session.write(m_packet, this, 9 + path.Length + attr.Length() + 4); }
private void sendMKDIR(byte[] path, SftpATTRS attr) { m_packet.reset(); putHEAD(SSH_FXP_MKDIR, 9 + path.Length + (attr != null ? attr.Length() : 4)); m_buffer.putInt(m_seq++); m_buffer.putString(path); // path if (attr != null) attr.dump(m_buffer); else m_buffer.putInt(0); m_session.write(m_packet, this, 9 + path.Length + (attr != null ? attr.Length() : 4) + 4); }
public void setStat(string path, SftpATTRS attr) { try { path = remoteAbsolutePath(path); List<string> v = glob_remote(path); int vsize = v.Count; for (int j = 0; j < vsize; j++) { path = v[j]; _setStat(path, attr); } } catch (Exception e) { if (e is SftpException) throw (SftpException)e; throw new SftpException(ChannelSftpResult.SSH_FX_FAILURE, ""); } }