本文整理汇总了C#中Tamir.SharpSsh.java.String.length方法的典型用法代码示例。如果您正苦于以下问题:C# String.length方法的具体用法?C# String.length怎么用?C# String.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tamir.SharpSsh.java.String
的用法示例。
在下文中一共展示了String.length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: get
public void get(String src, String dst,
SftpProgressMonitor monitor, int mode)
{
//throws SftpException{
src=remoteAbsolutePath(src);
dst=localAbsolutePath(dst);
try
{
Vector v=glob_remote(src);
int vsize=v.size();
if(vsize==0)
{
throw new SftpException(SSH_FX_NO_SUCH_FILE, "No such file");
}
File dstFile=new File(dst);
bool isDstDir=dstFile.isDirectory();
StringBuffer dstsb=null;
if(isDstDir)
{
if(!dst.endsWith(file_separator))
{
dst+=file_separator;
}
dstsb=new StringBuffer(dst);
}
else if(vsize>1)
{
throw new SftpException(SSH_FX_FAILURE, "Copying multiple files, but destination is missing or a file.");
}
for(int j=0; j<vsize; j++)
{
String _src=(String)(v.elementAt(j));
SftpATTRS attr=_stat(_src);
if(attr.isDir())
{
throw new SftpException(SSH_FX_FAILURE, "not supported to get directory "+_src);
}
String _dst=null;
if(isDstDir)
{
int i=_src.lastIndexOf('/');
if(i==-1) dstsb.append(_src);
else dstsb.append(_src.substring(i + 1));
_dst=dstsb.toString();
dstsb.delete(dst.length(), _dst.length());
}
else
{
_dst=dst;
}
if(mode==RESUME)
{
long size_of_src=attr.getSize();
long size_of_dst=new File(_dst).length();
if(size_of_dst>size_of_src)
{
throw new SftpException(SSH_FX_FAILURE, "failed to resume for "+_dst);
}
if(size_of_dst==size_of_src)
{
return;
}
}
if(monitor!=null)
{
monitor.init(SftpProgressMonitor.GET, _src, _dst, attr.getSize());
if(mode==RESUME)
{
monitor.count(new File(_dst).length());
}
}
FileOutputStream fos=null;
if(mode==OVERWRITE)
{
fos=new FileOutputStream(_dst);
}
else
{
fos=new FileOutputStream(_dst, true); // append
}
//System.err.println("_get: "+_src+", "+_dst);
_get(_src, fos, monitor, mode, new File(_dst).length());
fos.close();
}
}
catch(Exception e)
{
if(e is SftpException) throw (SftpException)e;
throw new SftpException(SSH_FX_FAILURE, "");
}
}
示例2: put
public void put(String src, String dst,
SftpProgressMonitor monitor, int mode)
{
//throws SftpException{
src=localAbsolutePath(src);
dst=remoteAbsolutePath(dst);
//System.err.println("src: "+src+", "+dst);
try
{
Vector v=glob_remote(dst);
int vsize=v.size();
if(vsize!=1)
{
if(vsize==0)
{
if(isPattern(dst))
throw new SftpException(SSH_FX_FAILURE, dst);
else
dst=Util.unquote(dst);
}
throw new SftpException(SSH_FX_FAILURE, v.toString());
}
else
{
dst=(String)(v.elementAt(0));
}
//System.err.println("dst: "+dst);
bool _isRemoteDir=isRemoteDir(dst);
v=glob_local(src);
//System.err.println("glob_local: "+v+" dst="+dst);
vsize=v.size();
StringBuffer dstsb=null;
if(_isRemoteDir)
{
if(!dst.endsWith("/"))
{
dst+="/";
}
dstsb=new StringBuffer(dst);
}
else if(vsize>1)
{
throw new SftpException(SSH_FX_FAILURE, "Copying multiple files, but destination is missing or a file.");
}
for(int j=0; j<vsize; j++)
{
String _src=(String)(v.elementAt(j));
String _dst=null;
if(_isRemoteDir)
{
int i=_src.lastIndexOf(file_separatorc);
if(i==-1) dstsb.append(_src);
else dstsb.append(_src.substring(i + 1));
_dst=dstsb.toString();
dstsb.delete(dst.length(), _dst.length());
}
else
{
_dst=dst;
}
//System.err.println("_dst "+_dst);
long size_of_dst=0;
if(mode==RESUME)
{
try
{
SftpATTRS attr=_stat(_dst);
size_of_dst=attr.getSize();
}
catch(Exception eee)
{
//System.err.println(eee);
}
long size_of_src=new File(_src).length();
if(size_of_src<size_of_dst)
{
throw new SftpException(SSH_FX_FAILURE, "failed to resume for "+_dst);
}
if(size_of_src==size_of_dst)
{
return;
}
}
if(monitor!=null)
{
monitor.init(SftpProgressMonitor.PUT, _src, _dst,
(new File(_src)).length());
if(mode==RESUME)
{
monitor.count(size_of_dst);
}
}
//.........这里部分代码省略.........