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


Java Packet.SSH_FXP_NAME属性代码示例

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


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

示例1: readLink

/**
 * Read the target of a symbolic link.
 * 
 * @param path See the {@link SFTPv3Client comment} for the class for more details.
 * @return The target of the link.
 * @throws IOException
 */
public String readLink(String path) throws IOException
{
	int req_id = generateNextRequestID();

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

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

	sendMessage(Packet.SSH_FXP_READLINK, 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);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:55,代码来源:SFTPv3Client.java

示例2: canonicalPath

/**
 * 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.
 * 
 * @param path See the {@link SFTPv3Client comment} for the class for more details.
 * @return An absolute path.
 * @throws IOException
 */
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)
	{
		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);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:57,代码来源:SFTPv3Client.java

示例3: scanDirectory

private final Vector scanDirectory(byte[] handle) throws IOException
{
	Vector files = new Vector();

	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());
	
		/* Some servers send here a packet with size > 34000 */
		/* To whom it may concern: please learn to read the specs. */
		
		byte[] resp = receiveMessage(65536);

		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 (debug != null)
				debug.println("Parsing " + count + " name entries...");

			while (count > 0)
			{
				SFTPv3DirectoryEntry dirEnt = new SFTPv3DirectoryEntry();

				dirEnt.filename = tr.readString(charsetName);
				dirEnt.longEntry = tr.readString(charsetName);

				dirEnt.attributes = readAttrs(tr);
				files.addElement(dirEnt);

				if (debug != null)
					debug.println("File: '" + dirEnt.filename + "'");
				count--;
			}
			continue;
		}

		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_EOF)
			return files;

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

示例4: canonicalPath

/**
 * 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.
 * 
 * @param path
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @return An absolute path.
 * @throws IOException
 */
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) {
		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);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:58,代码来源:SFTPv3Client.java

示例5: readLink

/**
 * Read the target of a symbolic link.
 * 
 * @param path
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @return The target of the link.
 * @throws IOException
 */
public String readLink(String path) throws IOException {
	int req_id = generateNextRequestID();

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

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

	sendMessage(Packet.SSH_FXP_READLINK, 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);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:56,代码来源:SFTPv3Client.java

示例6: scanDirectory

private final Vector scanDirectory(byte[] handle) throws IOException {
	Vector files = new Vector();

	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());

		/* Some servers send here a packet with size > 34000 */
		/* To whom it may concern: please learn to read the specs. */

		byte[] resp = receiveMessage(65536);

		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 (debug != null)
				debug.println("Parsing " + count + " name entries...");

			while (count > 0) {
				SFTPv3DirectoryEntry dirEnt = new SFTPv3DirectoryEntry();

				dirEnt.filename = tr.readString(charsetName);
				dirEnt.longEntry = tr.readString(charsetName);

				dirEnt.attributes = readAttrs(tr);
				files.addElement(dirEnt);

				if (debug != null)
					debug.println("File: '" + dirEnt.filename + "'");
				count--;
			}
			continue;
		}

		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_EOF)
			return files;

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


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