Package ch.ethz.ssh2.packets

Examples of ch.ethz.ssh2.packets.TypesWriter


    /* Either I am too stupid to understand the SFTP draft
     * or the OpenSSH guys changed the semantics of src and target.
     */

    TypesWriter tw = new TypesWriter();
    tw.writeString(target, charsetName);
    tw.writeString(src, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_SYMLINK...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here


   */
  public String canonicalPath(String path) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_REALPATH...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_REALPATH, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    if (debug != null)
    {
View Full Code Here

    while (true)
    {
      int req_id = generateNextRequestID();

      TypesWriter tw = new TypesWriter();
      tw.writeString(handle, 0, handle.length);

      if (debug != null)
      {
        debug.println("Sending SSH_FXP_READDIR...");
        debug.flush();
      }

      sendMessage(Packet.SSH_FXP_READDIR, req_id, tw.getBytes());

      byte[] resp = receiveMessage(34000);

      if (debug != null)
      {
View Full Code Here

  private final byte[] openDirectory(String path) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_OPENDIR...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_OPENDIR, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    TypesReader tr = new TypesReader(resp);
View Full Code Here

    final int client_version = 3;

    if (debug != null)
      debug.println("Sending SSH_FXP_INIT (" + client_version + ")...");

    TypesWriter tw = new TypesWriter();
    tw.writeUINT32(client_version);
    sendMessage(Packet.SSH_FXP_INIT, 0, tw.getBytes());

    /* Receive SSH_FXP_VERSION */

    if (debug != null)
      debug.println("Waiting for SSH_FXP_VERSION...");
View Full Code Here

   */
  public void mkdir(String dirName, int posixPermissions) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(dirName, charsetName);
    tw.writeUINT32(AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS);
    tw.writeUINT32(posixPermissions);

    sendMessage(Packet.SSH_FXP_MKDIR, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

   */
  public void rm(String fileName) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(fileName, charsetName);

    sendMessage(Packet.SSH_FXP_REMOVE, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

   */
  public void rmdir(String dirName) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(dirName, charsetName);

    sendMessage(Packet.SSH_FXP_RMDIR, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

   */
  public void mv(String oldPath, String newPath) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(oldPath, charsetName);
    tw.writeString(newPath, charsetName);

    sendMessage(Packet.SSH_FXP_RENAME, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

    return openFile(fileName, 0x00000018 | 0x00000003, attr); // SSH_FXF_CREAT | SSH_FXF_TRUNC | SSH_FXF_READ | SSH_FXF_WRITE
  }

  private byte[] createAttrs(SFTPv3FileAttributes attr)
  {
    TypesWriter tw = new TypesWriter();

    int attrFlags = 0;

    if (attr == null)
    {
      tw.writeUINT32(0);
    }
    else
    {
      if (attr.size != null)
        attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE;

      if ((attr.uid != null) && (attr.gid != null))
        attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID;

      if (attr.permissions != null)
        attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS;

      if ((attr.atime != null) && (attr.mtime != null))
        attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME;

      tw.writeUINT32(attrFlags);

      if (attr.size != null)
        tw.writeUINT64(attr.size.longValue());

      if ((attr.uid != null) && (attr.gid != null))
      {
        tw.writeUINT32(attr.uid.intValue());
        tw.writeUINT32(attr.gid.intValue());
      }

      if (attr.permissions != null)
        tw.writeUINT32(attr.permissions.intValue());

      if ((attr.atime != null) && (attr.mtime != null))
      {
        tw.writeUINT32(attr.atime.intValue());
        tw.writeUINT32(attr.mtime.intValue());
      }
    }

    return tw.getBytes();
  }
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.packets.TypesWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.