public void setClientVersion(String cv) { V_C=cv.getBytes(); }
/* cd /tmp c->s REALPATH s->c NAME c->s STAT s->c ATTR */ public void cd(String path) { //throws SftpException{ try { path=remoteAbsolutePath(path); Vector v=glob_remote(path); if(v.size()!=1) { throw new SftpException(SSH_FX_FAILURE, v.toString()); } path=(String)(v.elementAt(0)); sendREALPATH(path.getBytes()); Header _header=new Header(); _header=header(buf, _header); int length=_header.length; int type=_header.type; buf.rewind(); fill(buf.buffer, 0, length); if(type!=101 && type!=104) { throw new SftpException(SSH_FX_FAILURE, ""); } int i; if(type==101) { i=buf.getInt(); throwStatusError(buf, i); } i=buf.getInt(); byte[] str=buf.getString(); if(str!=null && str[0]!='/') { str=(cwd+"/"+new String(str)).getBytes(); } str=buf.getString(); // logname i=buf.getInt(); // attrs String newpwd=new String(str); SftpATTRS attr=_stat(newpwd); if((attr.getFlags()&SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS)==0) { throw new SftpException(SSH_FX_FAILURE, "Can't change directory: "+path); } if(!attr.isDir()) { throw new SftpException(SSH_FX_FAILURE, "Can't change directory: "+path); } cwd=newpwd; } catch(Exception e) { if(e is SftpException) throw (SftpException)e; throw new SftpException(SSH_FX_FAILURE, ""); } }