当前位置: 首页>>代码示例>>Java>>正文


Java TypesWriter.writeUINT64方法代码示例

本文整理汇总了Java中com.trilead.ssh2.packets.TypesWriter.writeUINT64方法的典型用法代码示例。如果您正苦于以下问题:Java TypesWriter.writeUINT64方法的具体用法?Java TypesWriter.writeUINT64怎么用?Java TypesWriter.writeUINT64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.trilead.ssh2.packets.TypesWriter的用法示例。


在下文中一共展示了TypesWriter.writeUINT64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAttrs

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
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();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:48,代码来源:SFTPv3Client.java

示例2: write

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
/**
 * Write bytes to a file. If <code>len</code> &gt; 32768, then the write operation will
 * be split into multiple writes.
 * 
 * @param handle a SFTPv3FileHandle handle.
 * @param fileOffset offset (in bytes) in the file.
 * @param src the source byte array.
 * @param srcoff offset in the source byte array.
 * @param len how many bytes to write.
 * @throws IOException
 */
public void write(SFTPv3FileHandle handle, long fileOffset, byte[] src, int srcoff, int len) throws IOException
{
	checkHandleValidAndOpen(handle);

	while (len > 0)
	{
		int writeRequestLen = len;

		if (writeRequestLen > 32768)
			writeRequestLen = 32768;

		int req_id = generateNextRequestID();

		TypesWriter tw = new TypesWriter();
		tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
		tw.writeUINT64(fileOffset);
		tw.writeString(src, srcoff, writeRequestLen);

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

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

		fileOffset += writeRequestLen;

		srcoff += writeRequestLen;
		len -= writeRequestLen;

		byte[] resp = receiveMessage(34000);

		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_STATUS)
			throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

		int errorCode = tr.readUINT32();

		if (errorCode == ErrorCodes.SSH_FX_OK)
			continue;

		String errorMessage = tr.readString();

		throw new SFTPException(errorMessage, errorCode);
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:66,代码来源:SFTPv3Client.java

示例3: createAttrs

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
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();
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:44,代码来源:SFTPv3Client.java

示例4: write

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
/**
 * Write bytes to a file. If <code>len</code> &gt; 32768, then the write
 * operation will be split into multiple writes.
 * 
 * @param handle
 *            a SFTPv3FileHandle handle.
 * @param fileOffset
 *            offset (in bytes) in the file.
 * @param src
 *            the source byte array.
 * @param srcoff
 *            offset in the source byte array.
 * @param len
 *            how many bytes to write.
 * @throws IOException
 */
public void write(SFTPv3FileHandle handle, long fileOffset, byte[] src,
		int srcoff, int len) throws IOException {
	checkHandleValidAndOpen(handle);

	while (len > 0) {
		int writeRequestLen = len;

		if (writeRequestLen > 32768)
			writeRequestLen = 32768;

		int req_id = generateNextRequestID();

		TypesWriter tw = new TypesWriter();
		tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
		tw.writeUINT64(fileOffset);
		tw.writeString(src, srcoff, writeRequestLen);

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

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

		fileOffset += writeRequestLen;

		srcoff += writeRequestLen;
		len -= writeRequestLen;

		byte[] resp = receiveMessage(34000);

		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_STATUS)
			throw new IOException(
					"The SFTP server sent an unexpected packet type (" + t
							+ ")");

		int errorCode = tr.readUINT32();

		if (errorCode == ErrorCodes.SSH_FX_OK)
			continue;

		String errorMessage = tr.readString();

		throw new SFTPException(errorMessage, errorCode);
	}
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:71,代码来源:SFTPv3Client.java


注:本文中的com.trilead.ssh2.packets.TypesWriter.writeUINT64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。