Logo Search packages:      
Sourcecode: jenkins-trilead-ssh2 version File versions  Download package

String com::trilead::ssh2::SFTPv3Client::canonicalPath ( String  path ) throws IOException [inline]

Have the server canonicalize any given path name to an absolute path. This is useful for converting path names containing ".." components or relative pathnames without a leading slash into absolute paths.

Parameters:
pathSee the comment for the class for more details.
Returns:
An absolute path.
Exceptions:
IOException

Definition at line 657 of file SFTPv3Client.java.

References receiveMessage().

      {
            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)
            {
                  debug.println("Got REPLY.");
                  debug.flush();
            }

            TypesReader tr = new TypesReader(resp);

            int t = tr.readByte();

            int rep_id = tr.readUINT32();
            if (rep_id != req_id)
                  throw new IOException("The server sent an invalid id field.");

            if (t == Packet.SSH_FXP_NAME)
            {
                  int count = tr.readUINT32();

                  if (count != 1)
                        throw new IOException("The server sent an invalid SSH_FXP_NAME packet.");

                  return tr.readString(charsetName);
            }

            if (t != Packet.SSH_FXP_STATUS)
                  throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

            int errorCode = tr.readUINT32();

            throw new SFTPException(tr.readString(), errorCode);
      }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index